[PATCH RFC] basic RMEDIA support for nvme host

Wang Yugui wangyugui at e16-tech.com
Tue Jul 23 16:24:19 PDT 2024


Rotational media(RMEDIA) support is added the NVMe 2.0 specification.
We firstly add Rotational media(RMEDIA) support to nvme host, then we can add
the support to nvme target later if the backstore is a Rotational media(RMEDIA)
block device.

Signed-off-by: Wang Yugui <wangyugui at e16-tech.com>
---
 drivers/nvme/host/core.c | 5 +++++
 include/linux/nvme.h     | 1 +
 2 files changed, 6 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 19917253ba7b..f4c41bf70b19 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -40,6 +40,7 @@ struct nvme_ns_info {
 	bool is_readonly;
 	bool is_ready;
 	bool is_removed;
+	bool is_rmedia;
 };
 
 unsigned int admin_timeout = 60;
@@ -1622,6 +1623,7 @@ static int nvme_ns_info_from_id_cs_indep(struct nvme_ctrl *ctrl,
 		info->is_shared = id->nmic & NVME_NS_NMIC_SHARED;
 		info->is_readonly = id->nsattr & NVME_NS_ATTR_RO;
 		info->is_ready = id->nstat & NVME_NSTAT_NRDY;
+		info->is_rmedia = id->nsfeat & NVME_INDEP_NS_FEAT_RMEDIA;
 	}
 	kfree(id);
 	return ret;
@@ -2164,6 +2166,9 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
 	else
 		lim.features &= ~(BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA);
 
+	if(info->is_rmedia)
+		lim.lim.features |= BLK_FEAT_ROTATIONAL;
+
 	/*
 	 * Register a metadata profile for PI, or the plain non-integrity NVMe
 	 * metadata masquerading as Type 0 if supported, otherwise reject block
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index c12a329dd463..2c259d126f80 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -546,6 +546,7 @@ enum {
 	NVME_NS_FEAT_THIN	= 1 << 0,
 	NVME_NS_FEAT_ATOMICS	= 1 << 1,
 	NVME_NS_FEAT_IO_OPT	= 1 << 4,
+	NVME_INDEP_NS_FEAT_RMEDIA = 1 << 4,
 	NVME_NS_ATTR_RO		= 1 << 0,
 	NVME_NS_FLBAS_LBA_MASK	= 0xf,
 	NVME_NS_FLBAS_LBA_UMASK	= 0x60,
-- 
2.36.2




More information about the Linux-nvme mailing list