Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-15048 control: Display NSID only when populated in storage query #14239

Merged
merged 1 commit into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions src/control/cmd/dmg/pretty/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,27 +176,34 @@ func PrintStorageFormatMap(hsm control.HostStorageMap, out io.Writer, opts ...Pr
return nil
}

// NVMe controller namespace ID (NSID) should only be displayed if >= 1. Zero value should be
// ignored in display output.
func printSmdDevice(dev *storage.SmdDevice, iw io.Writer, opts ...PrintConfigOption) error {
fc := getPrintConfig(opts...)

trAddr := fmt.Sprintf("TrAddr:%s", dev.Ctrlr.PciAddr)
nsID := fmt.Sprintf("NSID:%d", dev.CtrlrNamespaceID)
uid := fmt.Sprintf("UUID:%s", dev.UUID)
led := fmt.Sprintf("LED:%s", dev.Ctrlr.LedState)

if fc.LEDInfoOnly {
if _, err := fmt.Fprintf(iw, "TrAddr:%s NSID:%d", dev.Ctrlr.PciAddr,
dev.CtrlrNamespaceID); err != nil {
return err
out := trAddr
if dev.CtrlrNamespaceID > 0 {
out = fmt.Sprintf("%s %s", out, nsID)
}
if dev.UUID != "" {
if _, err := fmt.Fprintf(iw, " [UUID:%s]", dev.UUID); err != nil {
return err
}
}
if _, err := fmt.Fprintf(iw, " LED:%s\n", dev.Ctrlr.LedState); err != nil {
return err
out = fmt.Sprintf("%s [%s]", out, uid)
}
return nil

_, err := fmt.Fprintf(iw, "%s %s\n", out, led)
return err
}

if _, err := fmt.Fprintf(iw, "UUID:%s [TrAddr:%s NSID:%d]\n", dev.UUID, dev.Ctrlr.PciAddr,
dev.CtrlrNamespaceID); err != nil {
out := fmt.Sprintf("%s [%s", uid, trAddr)
if dev.CtrlrNamespaceID > 0 {
out = fmt.Sprintf("%s %s", out, nsID)
}
if _, err := fmt.Fprintf(iw, "%s]\n", out); err != nil {
return err
}

Expand Down
43 changes: 23 additions & 20 deletions src/control/cmd/dmg/pretty/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,25 +1518,28 @@ host1
SmdInfo: &control.SmdInfo{
Devices: []*storage.SmdDevice{
{
UUID: test.MockUUID(0),
TargetIDs: []int32{0, 1, 2},
HasSysXS: true,
Roles: storage.BdevRoles{storage.BdevRoleWAL},
Ctrlr: newCtrlr,
UUID: test.MockUUID(0),
TargetIDs: []int32{0, 1, 2},
HasSysXS: true,
Roles: storage.BdevRoles{storage.BdevRoleWAL},
Ctrlr: newCtrlr,
CtrlrNamespaceID: 1,
},
{
UUID: test.MockUUID(1),
TargetIDs: []int32{3, 4, 5},
Roles: storage.BdevRoles{storage.BdevRoleMeta | storage.BdevRoleData},
Ctrlr: faultCtrlr,
UUID: test.MockUUID(1),
TargetIDs: []int32{3, 4, 5},
Roles: storage.BdevRoles{storage.BdevRoleMeta | storage.BdevRoleData},
Ctrlr: faultCtrlr,
CtrlrNamespaceID: 1,
},
{
UUID: test.MockUUID(2),
TargetIDs: []int32{0, 1, 2},
Rank: 1,
HasSysXS: true,
Roles: storage.BdevRoles{storage.BdevRoleWAL},
Ctrlr: unknoCtrlr,
UUID: test.MockUUID(2),
TargetIDs: []int32{0, 1, 2},
Rank: 1,
HasSysXS: true,
Roles: storage.BdevRoles{storage.BdevRoleWAL},
Ctrlr: unknoCtrlr,
CtrlrNamespaceID: 1,
},
{
UUID: test.MockUUID(3),
Expand All @@ -1555,13 +1558,13 @@ host1
host1
-----
Devices
UUID:00000000-0000-0000-0000-000000000000 [TrAddr:0000:8a:00.0 NSID:0]
UUID:00000000-0000-0000-0000-000000000000 [TrAddr:0000:8a:00.0 NSID:1]
Roles:wal SysXS Targets:[0 1 2] Rank:0 State:NEW LED:OFF
UUID:00000001-0001-0001-0001-000000000001 [TrAddr:0000:8b:00.0 NSID:0]
UUID:00000001-0001-0001-0001-000000000001 [TrAddr:0000:8b:00.0 NSID:1]
Roles:data,meta Targets:[3 4 5] Rank:0 State:EVICTED LED:ON
UUID:00000002-0002-0002-0002-000000000002 [TrAddr:0000:da:00.0 NSID:0]
UUID:00000002-0002-0002-0002-000000000002 [TrAddr:0000:da:00.0 NSID:1]
Roles:wal SysXS Targets:[0 1 2] Rank:1 State:UNKNOWN LED:NA
UUID:00000003-0003-0003-0003-000000000003 [TrAddr:0000:db:00.0 NSID:0]
UUID:00000003-0003-0003-0003-000000000003 [TrAddr:0000:db:00.0]
knard38 marked this conversation as resolved.
Show resolved Hide resolved
Roles:data,meta Targets:[3 4 5] Rank:1 State:NORMAL LED:QUICK_BLINK
`,
},
Expand Down Expand Up @@ -1693,7 +1696,7 @@ host1
host1
-----
Devices
TrAddr:0000:db:00.0 NSID:0 [UUID:842c739b-86b5-462f-a7ba-b4a91b674f3d] LED:QUICK_BLINK
TrAddr:0000:db:00.0 [UUID:842c739b-86b5-462f-a7ba-b4a91b674f3d] LED:QUICK_BLINK
`,
},
"identify led; no uuid specified": {
Expand Down
Loading