[PATCH RFC 3/3] nvmet: report ns's vwc not present
Guixin Liu
kanie at linux.alibaba.com
Mon Nov 4 00:55:02 PST 2024
Currently, we report that controller has vwc even though the ns may
not have vwc. Report ns's vwc not present when not buffered_io or
backdev doesn't have vwc.
Signed-off-by: Guixin Liu <kanie at linux.alibaba.com>
---
drivers/nvme/target/admin-cmd.c | 36 +++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 081f0473cd9e..dffb84f560ad 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -685,6 +685,39 @@ static void nvmet_execute_identify_ctrl_nvm(struct nvmet_req *req)
nvmet_zero_sgl(req, 0, sizeof(struct nvme_id_ctrl_nvm)));
}
+static void nvmet_execute_identify_cs_indep(struct nvmet_req *req)
+{
+ struct nvme_id_ns_cs_indep *id;
+ u16 status;
+
+ status = nvmet_req_find_ns(req);
+ if (status)
+ goto out;
+
+ id = kzalloc(sizeof(*id), GFP_KERNEL);
+ if (!id) {
+ status = NVME_SC_INTERNAL;
+ goto out;
+ }
+
+ if ((req->ns->file && !req->ns->buffered_io) ||
+ (req->ns->bdev && !bdev_write_cache(req->ns->bdev)))
+ id->nsfeat |= NVME_NS_VWC_NOT_PRESENT;
+
+ id->nmic |= NVME_NS_NMIC_SHARED;
+ ///TODO: report reservation supported when that patch applied.
+ id->anagrpid = cpu_to_le32(req->ns->anagrpid);
+
+ if (req->ns->readonly)
+ id->nsattr |= NVME_NS_ATTR_RO;
+ id->nstat = NVME_NSTAT_NRDY;
+
+ status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id));
+ kfree(id);
+out:
+ nvmet_req_complete(req, status);
+}
+
static void nvmet_execute_identify(struct nvmet_req *req)
{
if (!nvmet_check_transfer_len(req, NVME_IDENTIFY_DATA_SIZE))
@@ -729,6 +762,9 @@ static void nvmet_execute_identify(struct nvmet_req *req)
break;
}
break;
+ case NVME_ID_CNS_NS_CS_INDEP:
+ nvmet_execute_identify_cs_indep(req);
+ return;
}
pr_debug("unhandled identify cns %d on qid %d\n",
--
2.43.0
More information about the Linux-nvme
mailing list