Skip to content

Commit

Permalink
DAOS-14422 control: Update pool create UX for MD-on-SSD phase2
Browse files Browse the repository at this point in the history
Features: control pool
Required-githooks: true

Signed-off-by: Tom Nabarro <[email protected]>
  • Loading branch information
tanabarr committed Jul 30, 2024
1 parent 38024fb commit 5efe997
Show file tree
Hide file tree
Showing 24 changed files with 1,110 additions and 986 deletions.
14 changes: 11 additions & 3 deletions src/common/dav_v2/dav_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,22 @@ dav_obj_create_v2(const char *path, int flags, size_t sz, mode_t mode, struct um
if (sz == 0) {
/* Open the file and obtain the size */
fd = open(path, O_RDWR|O_CLOEXEC);
if (fd == -1)
if (fd == -1) {
D_ERROR("obj_create_v2 open %s to fetch size: %s (%d)\n", path,
strerror(errno), errno);
return NULL;
}

if (fstat(fd, &statbuf) != 0)
goto out;
sz = statbuf.st_size;
} else {
fd = open(path, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, mode);
if (fd == -1)
if (fd == -1) {
D_ERROR("obj_create_v2 open %s to alloc: %s (%d)\n", path, strerror(errno),
errno);
return NULL;
}

if (fallocate(fd, 0, 0, (off_t)sz) == -1) {
errno = ENOSPC;
Expand Down Expand Up @@ -319,8 +325,10 @@ dav_obj_open_v2(const char *path, int flags, struct umem_store *store)
SUPPRESS_UNUSED(flags);

fd = open(path, O_RDWR|O_CLOEXEC);
if (fd == -1)
if (fd == -1) {
D_ERROR("obj_create_v2 open %s: %s (%d)\n", path, strerror(errno), errno);
return NULL;
}

if (fstat(fd, &statbuf) != 0) {
close(fd);
Expand Down
58 changes: 37 additions & 21 deletions src/control/cmd/daos/pretty/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package pretty
import (
"fmt"
"io"
"strings"

"github.com/dustin/go-humanize"
"github.com/pkg/errors"
Expand All @@ -19,14 +20,39 @@ import (

const msgNoPools = "No pools in system"

func getTierNameText(tierIdx int) string {
switch tierIdx {
case int(daos.StorageMediaTypeScm):
return fmt.Sprintf("- Storage tier %d (SCM):", tierIdx)
case int(daos.StorageMediaTypeNvme):
return fmt.Sprintf("- Storage tier %d (NVMe):", tierIdx)
default:
return fmt.Sprintf("- Storage tier %d (unknown):", tierIdx)
func printPoolTiers(suss []*daos.StorageUsageStats, w *txtfmt.ErrWriter, fullStats bool) {
mdOnSSD := false
for tierIdx, tierStats := range suss {
if tierIdx >= int(daos.StorageMediaTypeMax) {
tierStats.MediaType = daos.StorageMediaTypeMax // Print unknown type tier.
}

switch {
case tierIdx == 0 && tierStats.MediaType == daos.StorageMediaTypeNvme:
// MD-on-SSD mode.
// TODO: Print VOS index aggregate file size across pool as distinct from
// Meta-blob aggregate size.
if fullStats {
fmt.Fprintf(w, "- Total memory-file size: %s\n",
humanize.Bytes(tierStats.Total))
}
fmt.Fprintf(w, "- Metadata storage:\n")
mdOnSSD = true
case mdOnSSD:
fmt.Fprintf(w, "- Data storage:\n")
default:
fmt.Fprintf(w, "- Storage tier %d (%s):\n", tierIdx,
strings.ToUpper(tierStats.MediaType.String()))
}

fmt.Fprintf(w, " Total size: %s\n", humanize.Bytes(tierStats.Total))
if fullStats {
fmt.Fprintf(w, " Free: %s, min:%s, max:%s, mean:%s\n",
humanize.Bytes(tierStats.Free), humanize.Bytes(tierStats.Min),
humanize.Bytes(tierStats.Max), humanize.Bytes(tierStats.Mean))
} else {
fmt.Fprintf(w, " Free: %s\n", humanize.Bytes(tierStats.Free))
}
}
}

Expand Down Expand Up @@ -66,14 +92,8 @@ func PrintPoolInfo(pi *daos.PoolInfo, out io.Writer) error {

if pi.QueryMask.HasOption(daos.PoolQueryOptionSpace) && pi.TierStats != nil {
fmt.Fprintln(w, "Pool space info:")
fmt.Fprintf(w, "- Target(VOS) count:%d\n", pi.ActiveTargets)
for tierIdx, tierStats := range pi.TierStats {
fmt.Fprintln(w, getTierNameText(tierIdx))
fmt.Fprintf(w, " Total size: %s\n", humanize.Bytes(tierStats.Total))
fmt.Fprintf(w, " Free: %s, min:%s, max:%s, mean:%s\n",
humanize.Bytes(tierStats.Free), humanize.Bytes(tierStats.Min),
humanize.Bytes(tierStats.Max), humanize.Bytes(tierStats.Mean))
}
fmt.Fprintf(w, "- Target count:%d\n", pi.ActiveTargets)
printPoolTiers(pi.TierStats, w, true)
}
return w.Err
}
Expand All @@ -89,11 +109,7 @@ func PrintPoolQueryTargetInfo(pqti *daos.PoolQueryTargetInfo, out io.Writer) err
// Maintain output compatibility with the `daos pool query-targets` output.
fmt.Fprintf(w, "Target: type %s, state %s\n", pqti.Type, pqti.State)
if pqti.Space != nil {
for tierIdx, tierUsage := range pqti.Space {
fmt.Fprintln(w, getTierNameText(tierIdx))
fmt.Fprintf(w, " Total size: %s\n", humanize.Bytes(tierUsage.Total))
fmt.Fprintf(w, " Free: %s\n", humanize.Bytes(tierUsage.Free))
}
printPoolTiers(pqti.Space, w, false)
}

return w.Err
Expand Down
Loading

0 comments on commit 5efe997

Please sign in to comment.