NVMeCache: fix IdentifyMetric for namespace
We forgot to update the NSID for NS IdentifyMetric. And the log used the
incorrect path for namespace.
Google-Bug-Id: 406086758
Tested: b/406086758#comment#3
Signed-off-by: Hao Jiang <jianghao@google.com>
Change-Id: I4a96a4625388a4f27d80484bb21d8fdeb0e0a987
diff --git a/src/NVMeCacheImpl.hpp b/src/NVMeCacheImpl.hpp
index 2ab6fb7..0f5968f 100644
--- a/src/NVMeCacheImpl.hpp
+++ b/src/NVMeCacheImpl.hpp
@@ -172,6 +172,9 @@
ClockType::duration interval) :
MetricBase<ClockType>(scheduler, interval)
{
+ assert(resource &&
+ "Fail to construct Identify Metric on empty resource");
+ path = resource->path;
if constexpr (CNS == NVME_IDENTIFY_CNS_CTRL)
{
controller = resource;
@@ -183,7 +186,7 @@
assert(subsys &&
"Fail to construct NS Identify Metric on expired subsystem");
controller = subsys->getPrimaryController();
- resource->namespaceId();
+ namespaceId = resource->namespaceId();
}
else
{
@@ -236,9 +239,9 @@
cntrlPtr->nvmeIntf->adminIdentify(
cntrlPtr->nvmeCtrl, CNS, namespaceId,
0 /* CNTID will not be used for CNS = 00h/01h */,
- [weakSelf{std::move(this->weak_from_this())}, startTime,
- path{cntrlPtr->path}, id{getIdentifier()}, cb{std::move(cb)}](
- const nvme_ex_ptr& ex, std::span<uint8_t> data) {
+ [weakSelf{std::move(this->weak_from_this())}, startTime, path{path},
+ id{getIdentifier()}, cb{std::move(cb)}](const nvme_ex_ptr& ex,
+ std::span<uint8_t> data) {
auto self =
std::dynamic_pointer_cast<IdentifyMetric<CNS, ClockType>>(
weakSelf.lock());
@@ -289,6 +292,7 @@
}
/* member variables */
+ std::string path;
std::weak_ptr<NVMeControllerEnabled> controller;
uint32_t namespaceId;