diff --git a/src/control/cmd/dmg/pretty/storage_nvme.go b/src/control/cmd/dmg/pretty/storage_nvme.go index 4b6b2a19d65e..3e6441beb2f5 100644 --- a/src/control/cmd/dmg/pretty/storage_nvme.go +++ b/src/control/cmd/dmg/pretty/storage_nvme.go @@ -17,6 +17,7 @@ import ( "github.com/daos-stack/daos/src/control/common" "github.com/daos-stack/daos/src/control/lib/control" + "github.com/daos-stack/daos/src/control/lib/ranklist" "github.com/daos-stack/daos/src/control/lib/txtfmt" "github.com/daos-stack/daos/src/control/server/storage" ) @@ -216,12 +217,13 @@ func PrintNvmeControllers(controllers storage.NvmeControllers, out io.Writer, op pciTitle := "NVMe PCI" modelTitle := "Model" fwTitle := "FW Revision" - socketTitle := "Socket ID" + socketTitle := "Socket" capacityTitle := "Capacity" rolesTitle := "Role(s)" + rankTitle := "Rank" formatter := txtfmt.NewTableFormatter( - pciTitle, modelTitle, fwTitle, socketTitle, capacityTitle, rolesTitle, + pciTitle, modelTitle, fwTitle, socketTitle, capacityTitle, rolesTitle, rankTitle, ) formatter.InitWriter(out) var table []txtfmt.TableRow @@ -235,11 +237,17 @@ func PrintNvmeControllers(controllers storage.NvmeControllers, out io.Writer, op row[socketTitle] = fmt.Sprint(ctrlr.SocketID) row[capacityTitle] = humanize.Bytes(ctrlr.Capacity()) roles := "???" - // Assumes that all SMD devices on a controller have the same roles. + rank := "None" + // Assumes that all SMD devices on a controller have the same roles and rank. if len(ctrlr.SmdDevices) > 0 { - roles = fmt.Sprintf("%s", &ctrlr.SmdDevices[0].Roles) + sd := ctrlr.SmdDevices[0] + roles = fmt.Sprintf("%s", &sd.Roles) + if sd.Rank != ranklist.NilRank { + rank = sd.Rank.String() + } } row[rolesTitle] = roles + row[rankTitle] = rank table = append(table, row) } diff --git a/src/control/cmd/dmg/pretty/storage_nvme_test.go b/src/control/cmd/dmg/pretty/storage_nvme_test.go index 6c2b05eb94eb..aac7cbd17ee7 100644 --- a/src/control/cmd/dmg/pretty/storage_nvme_test.go +++ b/src/control/cmd/dmg/pretty/storage_nvme_test.go @@ -17,6 +17,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/daos-stack/daos/src/control/lib/control" + "github.com/daos-stack/daos/src/control/lib/ranklist" "github.com/daos-stack/daos/src/control/server/storage" ) @@ -25,6 +26,7 @@ func TestPretty_PrintNVMeController(t *testing.T) { c := storage.MockNvmeController(idx) sd := storage.MockSmdDevice(nil, idx) sd.Roles = storage.BdevRoles{storage.OptionBits(roleBits)} + sd.Rank = ranklist.Rank(idx) c.SmdDevices = []*storage.SmdDevice{sd} return c } @@ -38,10 +40,10 @@ func TestPretty_PrintNVMeController(t *testing.T) { storage.MockNvmeController(2), }, expPrintStr: ` -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB ??? -0000:02:00.0 model-2 fwRev-2 0 2.0 TB ??? +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB ??? None +0000:02:00.0 model-2 fwRev-2 0 2.0 TB ??? None `, }, "vmd backing devices": { @@ -50,10 +52,10 @@ NVMe PCI Model FW Revision Socket ID Capacity Role(s) &storage.NvmeController{PciAddr: "050505:03:00.0"}, }, expPrintStr: ` -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -050505:01:00.0 0 0 B ??? -050505:03:00.0 0 0 B ??? +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +050505:01:00.0 0 0 B ??? None +050505:03:00.0 0 0 B ??? None `, }, "controllers with roles": { @@ -62,10 +64,10 @@ NVMe PCI Model FW Revision Socket ID Capacity Role(s) ctrlrWithSmd(2, 6), }, expPrintStr: ` -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB data -0000:02:00.0 model-2 fwRev-2 0 2.0 TB meta,wal +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB data 1 +0000:02:00.0 model-2 fwRev-2 0 2.0 TB meta,wal 2 `, }, } { diff --git a/src/control/cmd/dmg/pretty/storage_scm.go b/src/control/cmd/dmg/pretty/storage_scm.go index 62123550d9f8..cffdaae5b90b 100644 --- a/src/control/cmd/dmg/pretty/storage_scm.go +++ b/src/control/cmd/dmg/pretty/storage_scm.go @@ -54,10 +54,10 @@ func PrintScmModules(modules storage.ScmModules, out io.Writer, opts ...PrintCon return w.Err } - physicalIdTitle := "SCM Module ID" - socketTitle := "Socket ID" - memCtrlrTitle := "Memory Ctrlr ID" - channelTitle := "Channel ID" + physicalIdTitle := "SCM Module" + socketTitle := "Socket" + memCtrlrTitle := "Memory Ctrlr" + channelTitle := "Channel" slotTitle := "Channel Slot" capacityTitle := "Capacity" @@ -96,7 +96,7 @@ func PrintScmNamespaces(namespaces storage.ScmNamespaces, out io.Writer, opts .. } deviceTitle := "SCM Namespace" - socketTitle := "Socket ID" + socketTitle := "Socket" capacityTitle := "Capacity" formatter := txtfmt.NewTableFormatter(deviceTitle, socketTitle, capacityTitle) diff --git a/src/control/cmd/dmg/pretty/storage_test.go b/src/control/cmd/dmg/pretty/storage_test.go index f06452688f0f..16a68884c476 100644 --- a/src/control/cmd/dmg/pretty/storage_test.go +++ b/src/control/cmd/dmg/pretty/storage_test.go @@ -474,9 +474,9 @@ host1 HugePage Size: 2048 KB No SCM modules found -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A 0 `, }, @@ -501,9 +501,9 @@ Errors: host1 ----- HugePage Size: 2048 KB -SCM Module ID Socket ID Memory Ctrlr ID Channel ID Channel Slot Capacity -------------- --------- --------------- ---------- ------------ -------- -1 1 1 1 1 954 MiB +SCM Module Socket Memory Ctrlr Channel Channel Slot Capacity +---------- ------ ------------ ------- ------------ -------- +1 1 1 1 1 954 MiB No NVMe devices found @@ -583,13 +583,13 @@ HugePage Size: 2048 KB host1 ----- HugePage Size: 2048 KB -SCM Module ID Socket ID Memory Ctrlr ID Channel ID Channel Slot Capacity -------------- --------- --------------- ---------- ------------ -------- -1 1 1 1 1 954 MiB +SCM Module Socket Memory Ctrlr Channel Channel Slot Capacity +---------- ------ ------------ ------- ------------ -------- +1 1 1 1 1 954 MiB -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A 0 `, }, @@ -609,13 +609,13 @@ NVMe PCI Model FW Revision Socket ID Capacity Role(s) host1 ----- HugePage Size: 2048 KB -SCM Namespace Socket ID Capacity -------------- --------- -------- -pmem0 0 1.0 TB +SCM Namespace Socket Capacity +------------- ------ -------- +pmem0 0 1.0 TB -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A 0 `, }, @@ -639,13 +639,13 @@ NVMe PCI Model FW Revision Socket ID Capacity Role(s) host[1-2] --------- HugePage Size: 2048 KB -SCM Module ID Socket ID Memory Ctrlr ID Channel ID Channel Slot Capacity -------------- --------- --------------- ---------- ------------ -------- -1 1 1 1 1 954 MiB +SCM Module Socket Memory Ctrlr Channel Channel Slot Capacity +---------- ------ ------------ ------- ------------ -------- +1 1 1 1 1 954 MiB -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A 0 `, }, @@ -669,9 +669,9 @@ NVMe PCI Model FW Revision Socket ID Capacity Role(s) host1 ----- HugePage Size: 2048 KB -SCM Module ID Socket ID Memory Ctrlr ID Channel ID Channel Slot Capacity -------------- --------- --------------- ---------- ------------ -------- -1 1 1 1 1 954 MiB +SCM Module Socket Memory Ctrlr Channel Channel Slot Capacity +---------- ------ ------------ ------- ------------ -------- +1 1 1 1 1 954 MiB No NVMe devices found @@ -681,9 +681,9 @@ host2 HugePage Size: 2048 KB No SCM modules found -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A 0 `, }, @@ -699,13 +699,13 @@ NVMe PCI Model FW Revision Socket ID Capacity Role(s) host[0-1023] ------------ HugePage Size: 2048 KB -SCM Module ID Socket ID Memory Ctrlr ID Channel ID Channel Slot Capacity -------------- --------- --------------- ---------- ------------ -------- -1 1 1 1 1 954 MiB +SCM Module Socket Memory Ctrlr Channel Channel Slot Capacity +---------- ------ ------------ ------- ------------ -------- +1 1 1 1 1 954 MiB -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A 0 `, }, @@ -739,9 +739,9 @@ host-[0001-0004] HugePage Size: 2048 KB No SCM modules found -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A 0 `, }, @@ -775,9 +775,9 @@ host-j-[0001-0004] HugePage Size: 2048 KB No SCM modules found -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 model-1 fwRev-1 1 2.0 TB N/A 0 `, }, @@ -809,29 +809,29 @@ NVMe PCI Model FW Revision Socket ID Capacity Role(s) host[1,3] --------- HugePage Size: 2048 KB -SCM Namespace Socket ID Capacity -------------- --------- -------- -pmem0 0 1.0 TB -pmem1 1 2.0 TB +SCM Namespace Socket Capacity +------------- ------ -------- +pmem0 0 1.0 TB +pmem1 1 2.0 TB -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 1 2.0 TB data,meta,wal -0000:04:00.0 0 2.0 TB data,meta,wal +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 1 2.0 TB data,meta,wal 0 +0000:04:00.0 0 2.0 TB data,meta,wal 0 --------- host[2,4] --------- HugePage Size: 2048 KB -SCM Namespace Socket ID Capacity -------------- --------- -------- -pmem0 0 1.0 TB -pmem1 1 2.0 TB - -NVMe PCI Model FW Revision Socket ID Capacity Role(s) --------- ----- ----------- --------- -------- ------- -0000:01:00.0 1 2.1 TB data,meta,wal -0000:04:00.0 0 2.1 TB data,meta,wal +SCM Namespace Socket Capacity +------------- ------ -------- +pmem0 0 1.0 TB +pmem1 1 2.0 TB + +NVMe PCI Model FW Revision Socket Capacity Role(s) Rank +-------- ----- ----------- ------ -------- ------- ---- +0000:01:00.0 1 2.1 TB data,meta,wal 0 +0000:04:00.0 0 2.1 TB data,meta,wal 0 `, }, diff --git a/src/control/server/ctl_storage.go b/src/control/server/ctl_storage.go index fa6dd85b9721..da3e6f19293f 100644 --- a/src/control/server/ctl_storage.go +++ b/src/control/server/ctl_storage.go @@ -101,25 +101,26 @@ func (cs *ControlService) getScmUsage(ssr *storage.ScmScanResponse) (*storage.Sc instances := cs.harness.Instances() - nss := make(storage.ScmNamespaces, len(instances)) - for idx, ei := range instances { - if !ei.IsReady() { + nss := make(storage.ScmNamespaces, 0, len(instances)) + for _, engine := range instances { + if !engine.IsReady() { continue // skip if not running } - cfg, err := ei.GetStorage().GetScmConfig() + cfg, err := engine.GetStorage().GetScmConfig() if err != nil { return nil, err } - mount, err := ei.GetStorage().GetScmUsage() + mount, err := engine.GetStorage().GetScmUsage() if err != nil { return nil, err } + var ns *storage.ScmNamespace switch mount.Class { case storage.ClassRam: // generate fake namespace for emulated ramdisk mounts - nss[idx] = &storage.ScmNamespace{ + ns = &storage.ScmNamespace{ Mount: mount, BlockDevice: "ramdisk", Size: uint64(humanize.GiByte * cfg.Scm.RamdiskSize), @@ -127,29 +128,32 @@ func (cs *ControlService) getScmUsage(ssr *storage.ScmScanResponse) (*storage.Sc case storage.ClassDcpm: // update namespace mount info for online storage if ssr.Namespaces == nil { return nil, errors.Errorf("instance %d: input scm scan response missing namespaces", - ei.Index()) + engine.Index()) } - ns := findPMemInScan(ssr, mount.DeviceList) + ns = findPMemInScan(ssr, mount.DeviceList) if ns == nil { return nil, errors.Errorf("instance %d: no pmem namespace for mount %s", - ei.Index(), mount.Path) + engine.Index(), mount.Path) } ns.Mount = mount - nss[idx] = ns } - if nss[idx].Mount != nil { - rank, err := ei.GetRank() + if ns.Mount != nil { + rank, err := engine.GetRank() if err != nil { return nil, errors.Wrapf(err, "instance %d: no rank associated for mount %s", - ei.Index(), mount.Path) + engine.Index(), mount.Path) } - nss[idx].Mount.Rank = rank + ns.Mount.Rank = rank } - cs.log.Debugf("updated scm fs usage on device %s mounted at %s: %+v", - nss[idx].BlockDevice, mount.Path, nss[idx].Mount) + cs.log.Debugf("updated scm fs usage on device %s mounted at %s: %+v", ns.BlockDevice, + mount.Path, ns.Mount) + nss = append(nss, ns) } + if len(nss) == 0 { + return nil, errors.New("no scm details found") + } return &storage.ScmScanResponse{Namespaces: nss}, nil } diff --git a/src/control/server/ctl_storage_rpc.go b/src/control/server/ctl_storage_rpc.go index 5ee6d71e1f63..474c7c5b0c55 100644 --- a/src/control/server/ctl_storage_rpc.go +++ b/src/control/server/ctl_storage_rpc.go @@ -270,7 +270,7 @@ func (cs *ControlService) scanScm(ctx context.Context, req *ctlpb.ScanScmReq) (* return nil, err } - resp, err := newScanScmResp(ssr) + resp, err := newScanScmResp(ssr, nil) if err != nil { return nil, err } diff --git a/src/control/server/ctl_storage_rpc_test.go b/src/control/server/ctl_storage_rpc_test.go index 65547b081604..71e7e891c557 100644 --- a/src/control/server/ctl_storage_rpc_test.go +++ b/src/control/server/ctl_storage_rpc_test.go @@ -716,7 +716,7 @@ func TestServer_CtlSvc_StorageScan(t *testing.T) { MemInfo: proto.MockPBMemInfo(), }, }, - "scan usage": { + "scan usage; engines not ready": { req: &ctlpb.StorageScanReq{ Scm: &ctlpb.ScanScmReq{ Usage: true, @@ -726,7 +726,7 @@ func TestServer_CtlSvc_StorageScan(t *testing.T) { }, }, enginesNotReady: true, - expErr: errEngineNotReady, + expErr: errors.New("no scm details found"), }, } { t.Run(name, func(t *testing.T) { diff --git a/src/control/server/instance_storage_rpc.go b/src/control/server/instance_storage_rpc.go index 0c4001dedf66..75b1057f4d91 100644 --- a/src/control/server/instance_storage_rpc.go +++ b/src/control/server/instance_storage_rpc.go @@ -219,11 +219,15 @@ func scanEngineBdevsOverDrpc(ctx context.Context, engine Engine, pbReq *ctlpb.Sc // Only minimal info provided in standard scan to enable result aggregation across // homogenous hosts. + engineRank, err := engine.GetRank() + if err != nil { + engine.Debugf("instance %d GetRank: %s", engine.Index(), err.Error()) + } nsd := &ctlpb.SmdDevice{ RoleBits: sd.RoleBits, CtrlrNamespaceId: sd.CtrlrNamespaceId, + Rank: engineRank.Uint32(), } - nsd.Ctrlr = nil // Populate health if requested. healthUpdated := false @@ -243,10 +247,7 @@ func scanEngineBdevsOverDrpc(ctx context.Context, engine Engine, pbReq *ctlpb.Sc // Populate usage data if requested. if pbReq.Meta { *nsd = *sd - engineRank, err := engine.GetRank() - if err != nil { - return nil, errors.Wrapf(err, "instance %d GetRank", engine.Index()) - } + nsd.Ctrlr = nil nsd.Rank = engineRank.Uint32() nsd.MetaSize = pbReq.MetaSize nsd.RdbSize = pbReq.RdbSize @@ -264,7 +265,7 @@ func scanEngineBdevsOverDrpc(ctx context.Context, engine Engine, pbReq *ctlpb.Sc } for _, c := range seenCtrlrs { - engine.Debugf("c: %+v, sds: %+v", c, c.SmdDevices) + engine.Debugf("ctrlr scanned: %+v", c) pbResp.Ctrlrs = append(pbResp.Ctrlrs, c) } diff --git a/src/control/server/instance_storage_rpc_test.go b/src/control/server/instance_storage_rpc_test.go index dfa0a28bd3bf..15a0642829b6 100644 --- a/src/control/server/instance_storage_rpc_test.go +++ b/src/control/server/instance_storage_rpc_test.go @@ -16,6 +16,7 @@ import ( "github.com/daos-stack/daos/src/control/common/proto" ctlpb "github.com/daos-stack/daos/src/control/common/proto/ctl" "github.com/daos-stack/daos/src/control/common/test" + "github.com/daos-stack/daos/src/control/lib/ranklist" "github.com/daos-stack/daos/src/control/logging" "github.com/daos-stack/daos/src/control/server/config" "github.com/daos-stack/daos/src/control/server/engine" @@ -27,11 +28,8 @@ import ( func TestIOEngineInstance_bdevScanEngine(t *testing.T) { c := storage.MockNvmeController(2) defSmdScanRes := func() *ctlpb.SmdDevResp { - return &ctlpb.SmdDevResp{ - Devices: []*ctlpb.SmdDevice{ - proto.MockSmdDevice(c, 2), - }, - } + sd := proto.MockSmdDevice(c, 2) + return &ctlpb.SmdDevResp{Devices: []*ctlpb.SmdDevice{sd}} } healthRespWithUsage := func() *ctlpb.BioHealthResp { mh := proto.MockNvmeHealth(2) @@ -43,6 +41,7 @@ func TestIOEngineInstance_bdevScanEngine(t *testing.T) { for name, tc := range map[string]struct { req ctlpb.ScanNvmeReq bdevAddrs []string + rank int provRes *storage.BdevScanResponse provErr error engStopped bool @@ -106,27 +105,52 @@ func TestIOEngineInstance_bdevScanEngine(t *testing.T) { provErr: errors.New("provider scan fail"), expErr: errors.New("provider scan fail"), }, - "scan over drpc; no health or meta": { - smdRes: defSmdScanRes(), - healthRes: proto.MockNvmeHealth(2), + "scan fails over drpc": { + smdErr: errors.New("drpc fail"), + expErr: errors.New("drpc fail"), + }, + "scan over drpc; no req flags; rank and roles populated": { + req: ctlpb.ScanNvmeReq{}, + rank: 1, + smdRes: defSmdScanRes(), expResp: &ctlpb.ScanNvmeResp{ Ctrlrs: proto.NvmeControllers{ func() *ctlpb.NvmeController { c := proto.MockNvmeController(2) c.HealthStats = nil - c.SmdDevices = nil + c.SmdDevices = []*ctlpb.SmdDevice{ + {Rank: 1, RoleBits: storage.BdevRoleAll}, + } return c }(), }, State: new(ctlpb.ResponseState), }, }, - "scan fails over drpc": { - smdErr: errors.New("drpc fail"), - expErr: errors.New("drpc fail"), + "scan over drpc; no req flags; invalid rank": { + req: ctlpb.ScanNvmeReq{}, + rank: -1, + smdRes: defSmdScanRes(), + expResp: &ctlpb.ScanNvmeResp{ + Ctrlrs: proto.NvmeControllers{ + func() *ctlpb.NvmeController { + c := proto.MockNvmeController(2) + c.HealthStats = nil + c.SmdDevices = []*ctlpb.SmdDevice{ + { + Rank: uint32(ranklist.NilRank), + RoleBits: storage.BdevRoleAll, + }, + } + return c + }(), + }, + State: new(ctlpb.ResponseState), + }, }, "scan over drpc; with health": { req: ctlpb.ScanNvmeReq{Health: true}, + rank: 1, smdRes: defSmdScanRes(), healthRes: healthRespWithUsage(), expResp: &ctlpb.ScanNvmeResp{ @@ -134,15 +158,18 @@ func TestIOEngineInstance_bdevScanEngine(t *testing.T) { func() *ctlpb.NvmeController { c := proto.MockNvmeController(2) c.HealthStats = healthRespWithUsage() - c.SmdDevices = nil + c.SmdDevices = []*ctlpb.SmdDevice{ + {Rank: 1, RoleBits: storage.BdevRoleAll}, + } return c }(), }, State: new(ctlpb.ResponseState), }, }, - "scan over drpc; with smd": { + "scan over drpc; with meta": { req: ctlpb.ScanNvmeReq{Meta: true}, + rank: 1, smdRes: defSmdScanRes(), healthRes: healthRespWithUsage(), expResp: &ctlpb.ScanNvmeResp{ @@ -150,9 +177,9 @@ func TestIOEngineInstance_bdevScanEngine(t *testing.T) { func() *ctlpb.NvmeController { c := proto.MockNvmeController(2) c.HealthStats = nil - c.SmdDevices = []*ctlpb.SmdDevice{ - proto.MockSmdDevice(nil, 2), - } + sd := proto.MockSmdDevice(nil, 2) + sd.Rank = 1 + c.SmdDevices = []*ctlpb.SmdDevice{sd} return c }(), }, @@ -161,6 +188,7 @@ func TestIOEngineInstance_bdevScanEngine(t *testing.T) { }, "scan over drpc; with smd and health; usage and wal size reported": { req: ctlpb.ScanNvmeReq{Meta: true, Health: true}, + rank: 1, smdRes: defSmdScanRes(), healthRes: healthRespWithUsage(), expResp: &ctlpb.ScanNvmeResp{ @@ -169,6 +197,7 @@ func TestIOEngineInstance_bdevScanEngine(t *testing.T) { c := proto.MockNvmeController(2) c.HealthStats = healthRespWithUsage() sd := proto.MockSmdDevice(nil, 2) + sd.Rank = 1 sd.TotalBytes = c.HealthStats.TotalBytes sd.AvailBytes = c.HealthStats.AvailBytes sd.ClusterSize = c.HealthStats.ClusterSize @@ -250,6 +279,13 @@ func TestIOEngineInstance_bdevScanEngine(t *testing.T) { cs := newMockControlServiceFromBackends(t, log, sCfg, bmb, smb, nil, tc.engStopped) ei := cs.harness.Instances()[0].(*EngineInstance) + if tc.rank < 0 { + ei.setSuperblock(nil) + } else { + ei.setSuperblock(&Superblock{ + Rank: ranklist.NewRankPtr(uint32(tc.rank)), ValidRank: true, + }) + } resp, err := bdevScanEngine(test.Context(t), ei, &tc.req) test.CmpErr(t, tc.expErr, err) diff --git a/src/control/server/storage/bdev.go b/src/control/server/storage/bdev.go index 8bf838134c52..648290913657 100644 --- a/src/control/server/storage/bdev.go +++ b/src/control/server/storage/bdev.go @@ -391,7 +391,7 @@ func (ncs NvmeControllers) String() string { for _, c := range ncs { s := c.PciAddr for _, sd := range c.SmdDevices { - s += fmt.Sprintf("-nsid%d-%s", sd.CtrlrNamespaceID, sd.Roles) + s += fmt.Sprintf("-nsid%d-%s", sd.CtrlrNamespaceID, sd.Roles.String()) } ss = append(ss, s) }