* [PATCH RFC] basic RMEDIA support for nvme host @ 2024-07-23 23:24 Wang Yugui 2024-07-24 12:30 ` [PATCH RFC v2] nvme: basic RMEDIA support for host Wang Yugui 2024-08-06 0:48 ` [PATCH RFC v3] " Wang Yugui 0 siblings, 2 replies; 15+ messages in thread From: Wang Yugui @ 2024-07-23 23:24 UTC (permalink / raw) To: linux-nvme; +Cc: Wang Yugui 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@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 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH RFC v2] nvme: basic RMEDIA support for host 2024-07-23 23:24 [PATCH RFC] basic RMEDIA support for nvme host Wang Yugui @ 2024-07-24 12:30 ` Wang Yugui 2024-07-25 0:43 ` Damien Le Moal 2024-07-25 14:09 ` Christoph Hellwig 2024-08-06 0:48 ` [PATCH RFC v3] " Wang Yugui 1 sibling, 2 replies; 15+ messages in thread From: Wang Yugui @ 2024-07-24 12:30 UTC (permalink / raw) To: linux-nvme; +Cc: Wang Yugui Rotational media(RMEDIA) support is added to 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@e16-tech.com> --- drivers/nvme/host/core.c | 5 +++++ drivers/nvme/host/multipath.c | 3 +++ drivers/nvme/host/nvme.h | 1 + include/linux/nvme.h | 1 + 4 files changed, 10 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; @@ -3613,6 +3618,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, head->ns_id = info->nsid; head->ids = info->ids; head->shared = info->is_shared; + head->rmedia = info->is_rmedia; ratelimit_state_init(&head->rs_nuse, 5 * HZ, 1); ratelimit_set_flags(&head->rs_nuse, RATELIMIT_MSG_ON_RELEASE); kref_init(&head->ref); @@ -3816,6 +3816,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info) if (ctrl->opts && ctrl->opts->data_digest) lim.features |= BLK_FEAT_STABLE_WRITES; + if (info->is_rmedia) + lim.features |= BLK_FEAT_ROTATIONAL; if (ctrl->ops->supports_pci_p2pdma && ctrl->ops->supports_pci_p2pdma(ctrl)) lim.features |= BLK_FEAT_PCI_P2PDMA; diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 91d9eb3c22ef..a3cd6525d24d 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -626,6 +626,9 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) head->disk->private_data = head; sprintf(head->disk->disk_name, "nvme%dn%d", ctrl->subsys->instance, head->instance); + + if(head->rmedia) + lim.features |= BLK_FEAT_ROTATIONAL; return 0; } diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index f900e44243ae..9f2789c44249 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -465,6 +465,7 @@ struct nvme_ns_head { struct list_head entry; struct kref ref; bool shared; + bool rmedia; bool passthru_err_log_enabled; int instance; struct nvme_effects_log *effects; 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 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH RFC v2] nvme: basic RMEDIA support for host 2024-07-24 12:30 ` [PATCH RFC v2] nvme: basic RMEDIA support for host Wang Yugui @ 2024-07-25 0:43 ` Damien Le Moal 2024-07-25 1:56 ` Wang Yugui 2024-07-25 14:10 ` Christoph Hellwig 2024-07-25 14:09 ` Christoph Hellwig 1 sibling, 2 replies; 15+ messages in thread From: Damien Le Moal @ 2024-07-25 0:43 UTC (permalink / raw) To: Wang Yugui, linux-nvme On 7/24/24 21:30, Wang Yugui wrote: > Rotational media(RMEDIA) support is added to 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. Why not do that now in another patch, at least for the loop target ? Given that they are not that many NVMe-HDD out there, that would be nice to have to test this. > > Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> > --- > drivers/nvme/host/core.c | 5 +++++ > drivers/nvme/host/multipath.c | 3 +++ > drivers/nvme/host/nvme.h | 1 + > include/linux/nvme.h | 1 + > 4 files changed, 10 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; > @@ -3613,6 +3618,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, > head->ns_id = info->nsid; > head->ids = info->ids; > head->shared = info->is_shared; > + head->rmedia = info->is_rmedia; > ratelimit_state_init(&head->rs_nuse, 5 * HZ, 1); > ratelimit_set_flags(&head->rs_nuse, RATELIMIT_MSG_ON_RELEASE); > kref_init(&head->ref); > @@ -3816,6 +3816,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info) > > if (ctrl->opts && ctrl->opts->data_digest) > lim.features |= BLK_FEAT_STABLE_WRITES; > + if (info->is_rmedia) > + lim.features |= BLK_FEAT_ROTATIONAL; > if (ctrl->ops->supports_pci_p2pdma && > ctrl->ops->supports_pci_p2pdma(ctrl)) > lim.features |= BLK_FEAT_PCI_P2PDMA; > diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c > index 91d9eb3c22ef..a3cd6525d24d 100644 > --- a/drivers/nvme/host/multipath.c > +++ b/drivers/nvme/host/multipath.c > @@ -626,6 +626,9 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) > head->disk->private_data = head; > sprintf(head->disk->disk_name, "nvme%dn%d", > ctrl->subsys->instance, head->instance); > + > + if(head->rmedia) > + lim.features |= BLK_FEAT_ROTATIONAL; > return 0; > } > > diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h > index f900e44243ae..9f2789c44249 100644 > --- a/drivers/nvme/host/nvme.h > +++ b/drivers/nvme/host/nvme.h > @@ -465,6 +465,7 @@ struct nvme_ns_head { > struct list_head entry; > struct kref ref; > bool shared; > + bool rmedia; > bool passthru_err_log_enabled; > int instance; > struct nvme_effects_log *effects; > 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, -- Damien Le Moal Western Digital Research ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH RFC v2] nvme: basic RMEDIA support for host 2024-07-25 0:43 ` Damien Le Moal @ 2024-07-25 1:56 ` Wang Yugui 2024-07-25 14:10 ` Christoph Hellwig 1 sibling, 0 replies; 15+ messages in thread From: Wang Yugui @ 2024-07-25 1:56 UTC (permalink / raw) To: Damien Le Moal; +Cc: linux-nvme Hi, > On 7/24/24 21:30, Wang Yugui wrote: > > Rotational media(RMEDIA) support is added to 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. > > Why not do that now in another patch, at least for the loop target ? Given that > they are not that many NVMe-HDD out there, that would be nice to have to test this. Just because yet not enough skill/time now. Best Regards Wang Yugui (wangyugui@e16-tech.com) 2024/07/25 ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH RFC v2] nvme: basic RMEDIA support for host 2024-07-25 0:43 ` Damien Le Moal 2024-07-25 1:56 ` Wang Yugui @ 2024-07-25 14:10 ` Christoph Hellwig 2024-07-25 22:59 ` Damien Le Moal 1 sibling, 1 reply; 15+ messages in thread From: Christoph Hellwig @ 2024-07-25 14:10 UTC (permalink / raw) To: Damien Le Moal; +Cc: Wang Yugui, linux-nvme On Thu, Jul 25, 2024 at 09:43:45AM +0900, Damien Le Moal wrote: > Why not do that now in another patch, at least for the loop target ? > Given that they are not that many NVMe-HDD out there, that would be > nice to have to test this. The code would be in the bdev backend, so it applies to all transport equally. And yes, I'd love to see a patch for that to, but I don't want to gate a simple flag check on it. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH RFC v2] nvme: basic RMEDIA support for host 2024-07-25 14:10 ` Christoph Hellwig @ 2024-07-25 22:59 ` Damien Le Moal 2024-08-12 14:28 ` Hannes Reinecke 0 siblings, 1 reply; 15+ messages in thread From: Damien Le Moal @ 2024-07-25 22:59 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Wang Yugui, linux-nvme On 7/25/24 23:10, Christoph Hellwig wrote: > On Thu, Jul 25, 2024 at 09:43:45AM +0900, Damien Le Moal wrote: >> Why not do that now in another patch, at least for the loop target ? >> Given that they are not that many NVMe-HDD out there, that would be >> nice to have to test this. > > The code would be in the bdev backend, so it applies to all transport > equally. And yes, I'd love to see a patch for that to, but I don't > want to gate a simple flag check on it. OK. Will look into it then. I have the setup to test this anyway. That said, while setting only the rotational media bit should be fairly easy, I am worried about spec compliance as setting that flag to 1 mandates support for endurance groups as well. Do we care about this ? I am tempted to say no but not following the specs is generally a dangerous path we do not want to follow... -- Damien Le Moal Western Digital Research ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH RFC v2] nvme: basic RMEDIA support for host 2024-07-25 22:59 ` Damien Le Moal @ 2024-08-12 14:28 ` Hannes Reinecke 0 siblings, 0 replies; 15+ messages in thread From: Hannes Reinecke @ 2024-08-12 14:28 UTC (permalink / raw) To: Damien Le Moal, Christoph Hellwig; +Cc: Wang Yugui, linux-nvme On 7/26/24 00:59, Damien Le Moal wrote: > On 7/25/24 23:10, Christoph Hellwig wrote: >> On Thu, Jul 25, 2024 at 09:43:45AM +0900, Damien Le Moal wrote: >>> Why not do that now in another patch, at least for the loop target ? >>> Given that they are not that many NVMe-HDD out there, that would be >>> nice to have to test this. >> >> The code would be in the bdev backend, so it applies to all transport >> equally. And yes, I'd love to see a patch for that to, but I don't >> want to gate a simple flag check on it. > > OK. Will look into it then. I have the setup to test this anyway. > > That said, while setting only the rotational media bit should be fairly easy, I > am worried about spec compliance as setting that flag to 1 mandates support for > endurance groups as well. Do we care about this ? I am tempted to say no but not > following the specs is generally a dangerous path we do not want to follow... > I'd got for the usual minimal-viable implementation way like adding static logpages for the endurance group information (with just a single endurance group '1') and for endurance group event aggregate (with no events :-). Shouldn't blow up the code _that_ much. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH RFC v2] nvme: basic RMEDIA support for host 2024-07-24 12:30 ` [PATCH RFC v2] nvme: basic RMEDIA support for host Wang Yugui 2024-07-25 0:43 ` Damien Le Moal @ 2024-07-25 14:09 ` Christoph Hellwig 1 sibling, 0 replies; 15+ messages in thread From: Christoph Hellwig @ 2024-07-25 14:09 UTC (permalink / raw) To: Wang Yugui; +Cc: linux-nvme On Wed, Jul 24, 2024 at 08:30:52PM +0800, Wang Yugui wrote: > Rotational media(RMEDIA) support is added to 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. I'd reword this a bit: Subject: nvme: add support for the rotational media flag Add support for the rotational media (RMEDIA) flag in the NVMe 2.0 specification by propagating it to the block layer BLK_FEAT_ROTATIONAL flag. > + bool is_rmedia; I'd stick to the Linux 'rotational' terminology here, i.e. is_rotational. > + if(head->rmedia) missing whitespace after the if here. But as blk_stack_limits inherits BLK_FEAT_ROTATIONAL I think this shouldn't even be needed at all. ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH RFC v3] nvme: basic RMEDIA support for host 2024-07-23 23:24 [PATCH RFC] basic RMEDIA support for nvme host Wang Yugui 2024-07-24 12:30 ` [PATCH RFC v2] nvme: basic RMEDIA support for host Wang Yugui @ 2024-08-06 0:48 ` Wang Yugui 2024-08-06 0:49 ` [PATCH RFC] nvmet: basic RMEDIA support for target Wang Yugui 1 sibling, 1 reply; 15+ messages in thread From: Wang Yugui @ 2024-08-06 0:48 UTC (permalink / raw) To: linux-nvme; +Cc: Wang Yugui Rotational media(RMEDIA) support is added to the NVMe 2.0 specification. We add Rotational media(RMEDIA) basic support to nvme host firstly. Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> --- changelog of RFC v3 - rename var based on comments. change is_rmedia to is_rotational; but keep RMEDIA of NVME_INDEP_NS_FEAT_RMEDIA to match NVME spec 2.0. drivers/nvme/host/core.c | 5 +++++ drivers/nvme/host/multipath.c | 3 +++ drivers/nvme/host/nvme.h | 1 + include/linux/nvme.h | 1 + 4 files changed, 10 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_rotational; }; 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_rotational = id->nsfeat & NVME_INDEP_NS_FEAT_RMEDIA; } kfree(id); return ret; @@ -3613,6 +3618,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, head->ns_id = info->nsid; head->ids = info->ids; head->shared = info->is_shared; + head->rotational = info->is_rotational; ratelimit_state_init(&head->rs_nuse, 5 * HZ, 1); ratelimit_set_flags(&head->rs_nuse, RATELIMIT_MSG_ON_RELEASE); kref_init(&head->ref); @@ -3816,6 +3816,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info) if (ctrl->opts && ctrl->opts->data_digest) lim.features |= BLK_FEAT_STABLE_WRITES; + if (info->is_rotational) + lim.features |= BLK_FEAT_ROTATIONAL; if (ctrl->ops->supports_pci_p2pdma && ctrl->ops->supports_pci_p2pdma(ctrl)) lim.features |= BLK_FEAT_PCI_P2PDMA; diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 91d9eb3c22ef..a3cd6525d24d 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -626,6 +626,9 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head) head->disk->private_data = head; sprintf(head->disk->disk_name, "nvme%dn%d", ctrl->subsys->instance, head->instance); + + if (head->rotational) + lim.features |= BLK_FEAT_ROTATIONAL; return 0; } diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index f900e44243ae..9f2789c44249 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -465,6 +465,7 @@ struct nvme_ns_head { struct list_head entry; struct kref ref; bool shared; + bool rotational; bool passthru_err_log_enabled; int instance; struct nvme_effects_log *effects; 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 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH RFC] nvmet: basic RMEDIA support for target 2024-08-06 0:48 ` [PATCH RFC v3] " Wang Yugui @ 2024-08-06 0:49 ` Wang Yugui 2024-08-06 8:11 ` Sagi Grimberg ` (2 more replies) 0 siblings, 3 replies; 15+ messages in thread From: Wang Yugui @ 2024-08-06 0:49 UTC (permalink / raw) To: linux-nvme; +Cc: Wang Yugui Rotational media(RMEDIA) support is added to the NVMe 2.0 specification. We add Rotational media(RMEDIA) basic support to nvme target. Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> --- drivers/nvme/target/admin-cmd.c | 50 +++++++++++++++++++++++++++++++ drivers/nvme/target/core.c | 2 ++ drivers/nvme/target/io-cmd-bdev.c | 1 + drivers/nvme/target/nvmet.h | 1 + 4 files changed, 54 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index f7e1156ac7ec..20a28102f8a0 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -489,6 +489,53 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) nvmet_req_complete(req, status); } +static void nvmet_execute_identify_indep(struct nvmet_req *req) +{ + struct nvme_id_ns_cs_indep *id; + u16 status; + + id = kzalloc(sizeof(*id), GFP_KERNEL); + if (!id) { + status = NVME_SC_INTERNAL; + goto out; + } + + /* return an all zeroed buffer if we can't find an active namespace */ + status = nvmet_req_find_ns(req); + if (status) { + status = 0; + goto done; + } + + if (nvmet_ns_revalidate(req->ns)) { + mutex_lock(&req->ns->subsys->lock); + nvmet_ns_changed(req->ns->subsys, req->ns->nsid); + mutex_unlock(&req->ns->subsys->lock); + } + + /* + * Our namespace might always be shared. Not just with other + * controllers, but also with any other user of the block device. + */ + id->nmic = NVME_NS_NMIC_SHARED; + id->anagrpid = cpu_to_le32(req->ns->anagrpid); + + if (req->ns->readonly) + id->nsattr |= NVME_NS_ATTR_RO; + + id->nstat |= NVME_NSTAT_NRDY; + + if(req->ns->rotational) + id->nsfeat |= NVME_INDEP_NS_FEAT_RMEDIA; + +done: + if (!status) + status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); + kfree(id); +out: + nvmet_req_complete(req, status); +} + static void nvmet_execute_identify_ns(struct nvmet_req *req) { struct nvme_id_ns *id; @@ -706,6 +724,9 @@ static void nvmet_execute_identify(struct nvmet_req *req) break; } break; + case NVME_ID_CNS_NS_CS_INDEP: + nvmet_execute_identify_indep(req); + return; case NVME_ID_CNS_CS_CTRL: switch (req->cmd->identify.csi) { case NVME_CSI_NVM: diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index ed2424f8a396..2790fedb593b 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -1254,6 +1254,8 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl) else ctrl->cap |= ctrl->port->max_queue_size - 1; + ctrl->cap |= NVME_CAP_CRMS_CRIMS; + if (nvmet_is_passthru_subsys(ctrl->subsys)) nvmet_passthrough_override_cap(ctrl); } diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index 0bda83d0fc3e..d15ad1a864bc 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -104,6 +104,7 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns) ns->pi_type = 0; ns->metadata_size = 0; + ns->rotational = bdev_nonrot(ns->bdev); if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY)) nvmet_bdev_ns_enable_integrity(ns); diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 190f55e6d753..86eeeadf3787 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -62,6 +62,7 @@ struct nvmet_ns { struct block_device *bdev; struct file *file; bool readonly; + bool rotational; u32 nsid; u32 blksize_shift; loff_t size; -- 2.36.2 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH RFC] nvmet: basic RMEDIA support for target 2024-08-06 0:49 ` [PATCH RFC] nvmet: basic RMEDIA support for target Wang Yugui @ 2024-08-06 8:11 ` Sagi Grimberg 2024-08-06 9:08 ` Wang Yugui 2024-08-06 9:42 ` [PATCH RFC v2] " Wang Yugui 2024-08-06 12:40 ` [PATCH RFC v3] " Wang Yugui 2 siblings, 1 reply; 15+ messages in thread From: Sagi Grimberg @ 2024-08-06 8:11 UTC (permalink / raw) To: Wang Yugui, linux-nvme On 06/08/2024 3:49, Wang Yugui wrote: > Rotational media(RMEDIA) support is added to the NVMe 2.0 specification. > We add Rotational media(RMEDIA) basic support to nvme target. > > Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> > --- > drivers/nvme/target/admin-cmd.c | 50 +++++++++++++++++++++++++++++++ > drivers/nvme/target/core.c | 2 ++ > drivers/nvme/target/io-cmd-bdev.c | 1 + > drivers/nvme/target/nvmet.h | 1 + > 4 files changed, 54 insertions(+) > > diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c > index f7e1156ac7ec..20a28102f8a0 100644 > --- a/drivers/nvme/target/admin-cmd.c > +++ b/drivers/nvme/target/admin-cmd.c > @@ -489,6 +489,53 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) > nvmet_req_complete(req, status); > } > > +static void nvmet_execute_identify_indep(struct nvmet_req *req) > +{ > + struct nvme_id_ns_cs_indep *id; > + u16 status; > + > + id = kzalloc(sizeof(*id), GFP_KERNEL); > + if (!id) { > + status = NVME_SC_INTERNAL; > + goto out; > + } > + > + /* return an all zeroed buffer if we can't find an active namespace */ > + status = nvmet_req_find_ns(req); > + if (status) { > + status = 0; > + goto done; > + } > + > + if (nvmet_ns_revalidate(req->ns)) { > + mutex_lock(&req->ns->subsys->lock); > + nvmet_ns_changed(req->ns->subsys, req->ns->nsid); > + mutex_unlock(&req->ns->subsys->lock); > + } > + > + /* > + * Our namespace might always be shared. Not just with other > + * controllers, but also with any other user of the block device. > + */ > + id->nmic = NVME_NS_NMIC_SHARED; > + id->anagrpid = cpu_to_le32(req->ns->anagrpid); > + > + if (req->ns->readonly) > + id->nsattr |= NVME_NS_ATTR_RO; > + > + id->nstat |= NVME_NSTAT_NRDY; > + > + if(req->ns->rotational) > + id->nsfeat |= NVME_INDEP_NS_FEAT_RMEDIA; > + > +done: > + if (!status) > + status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); > + kfree(id); > +out: > + nvmet_req_complete(req, status); > +} > + > static void nvmet_execute_identify_ns(struct nvmet_req *req) > { > struct nvme_id_ns *id; > @@ -706,6 +724,9 @@ static void nvmet_execute_identify(struct nvmet_req *req) > break; > } > break; > + case NVME_ID_CNS_NS_CS_INDEP: > + nvmet_execute_identify_indep(req); > + return; > case NVME_ID_CNS_CS_CTRL: > switch (req->cmd->identify.csi) { > case NVME_CSI_NVM: > diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c > index ed2424f8a396..2790fedb593b 100644 > --- a/drivers/nvme/target/core.c > +++ b/drivers/nvme/target/core.c > @@ -1254,6 +1254,8 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl) > else > ctrl->cap |= ctrl->port->max_queue_size - 1; > > + ctrl->cap |= NVME_CAP_CRMS_CRIMS; > + > if (nvmet_is_passthru_subsys(ctrl->subsys)) > nvmet_passthrough_override_cap(ctrl); > } > diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c > index 0bda83d0fc3e..d15ad1a864bc 100644 > --- a/drivers/nvme/target/io-cmd-bdev.c > +++ b/drivers/nvme/target/io-cmd-bdev.c > @@ -104,6 +104,7 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns) > > ns->pi_type = 0; > ns->metadata_size = 0; > + ns->rotational = bdev_nonrot(ns->bdev); Shouldn't this be !bdev_nonrot(ns->bdev) ? ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH RFC] nvmet: basic RMEDIA support for target 2024-08-06 8:11 ` Sagi Grimberg @ 2024-08-06 9:08 ` Wang Yugui 0 siblings, 0 replies; 15+ messages in thread From: Wang Yugui @ 2024-08-06 9:08 UTC (permalink / raw) To: Sagi Grimberg; +Cc: linux-nvme Hi, > > On 06/08/2024 3:49, Wang Yugui wrote: > > Rotational media(RMEDIA) support is added to the NVMe 2.0 specification. > > We add Rotational media(RMEDIA) basic support to nvme target. > > > > Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> > > --- > > drivers/nvme/target/admin-cmd.c | 50 +++++++++++++++++++++++++++++++ > > drivers/nvme/target/core.c | 2 ++ > > drivers/nvme/target/io-cmd-bdev.c | 1 + > > drivers/nvme/target/nvmet.h | 1 + > > 4 files changed, 54 insertions(+) > > > > diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c > > index f7e1156ac7ec..20a28102f8a0 100644 > > --- a/drivers/nvme/target/admin-cmd.c > > +++ b/drivers/nvme/target/admin-cmd.c > > @@ -489,6 +489,53 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) > > nvmet_req_complete(req, status); > > } > > > +static void nvmet_execute_identify_indep(struct nvmet_req *req) > > +{ > > + struct nvme_id_ns_cs_indep *id; > > + u16 status; > > + > > + id = kzalloc(sizeof(*id), GFP_KERNEL); > > + if (!id) { > > + status = NVME_SC_INTERNAL; > > + goto out; > > + } > > + > > + /* return an all zeroed buffer if we can't find an active namespace */ > > + status = nvmet_req_find_ns(req); > > + if (status) { > > + status = 0; > > + goto done; > > + } > > + > > + if (nvmet_ns_revalidate(req->ns)) { > > + mutex_lock(&req->ns->subsys->lock); > > + nvmet_ns_changed(req->ns->subsys, req->ns->nsid); > > + mutex_unlock(&req->ns->subsys->lock); > > + } > > + > > + /* > > + * Our namespace might always be shared. Not just with other > > + * controllers, but also with any other user of the block device. > > + */ > > + id->nmic = NVME_NS_NMIC_SHARED; > > + id->anagrpid = cpu_to_le32(req->ns->anagrpid); > > + > > + if (req->ns->readonly) > > + id->nsattr |= NVME_NS_ATTR_RO; > > + > > + id->nstat |= NVME_NSTAT_NRDY; > > + > > + if(req->ns->rotational) > > + id->nsfeat |= NVME_INDEP_NS_FEAT_RMEDIA; > > + > > +done: > > + if (!status) > > + status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); > > + kfree(id); > > +out: > > + nvmet_req_complete(req, status); > > +} > > + > > static void nvmet_execute_identify_ns(struct nvmet_req *req) > > { > > struct nvme_id_ns *id; > > @@ -706,6 +724,9 @@ static void nvmet_execute_identify(struct nvmet_req *req) > > break; > > } > > break; > > + case NVME_ID_CNS_NS_CS_INDEP: > > + nvmet_execute_identify_indep(req); > > + return; > > case NVME_ID_CNS_CS_CTRL: > > switch (req->cmd->identify.csi) { > > case NVME_CSI_NVM: > > diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c > > index ed2424f8a396..2790fedb593b 100644 > > --- a/drivers/nvme/target/core.c > > +++ b/drivers/nvme/target/core.c > > @@ -1254,6 +1254,8 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl) > > else > > ctrl->cap |= ctrl->port->max_queue_size - 1; > > > + ctrl->cap |= NVME_CAP_CRMS_CRIMS; > > + > > if (nvmet_is_passthru_subsys(ctrl->subsys)) > > nvmet_passthrough_override_cap(ctrl); > > } > > diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c > > index 0bda83d0fc3e..d15ad1a864bc 100644 > > --- a/drivers/nvme/target/io-cmd-bdev.c > > +++ b/drivers/nvme/target/io-cmd-bdev.c > > @@ -104,6 +104,7 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns) > > > ns->pi_type = 0; > > ns->metadata_size = 0; > > + ns->rotational = bdev_nonrot(ns->bdev); > > Shouldn't this be !bdev_nonrot(ns->bdev) ? You are right. It will be fixed in next version. Thanks a lot. Best Regards Wang Yugui (wangyugui@e16-tech.com) 2024/08/06 ^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH RFC v2] nvmet: basic RMEDIA support for target 2024-08-06 0:49 ` [PATCH RFC] nvmet: basic RMEDIA support for target Wang Yugui 2024-08-06 8:11 ` Sagi Grimberg @ 2024-08-06 9:42 ` Wang Yugui 2024-08-06 12:40 ` [PATCH RFC v3] " Wang Yugui 2 siblings, 0 replies; 15+ messages in thread From: Wang Yugui @ 2024-08-06 9:42 UTC (permalink / raw) To: linux-nvme; +Cc: Wang Yugui Rotational media(RMEDIA) support is added to the NVMe 2.0 specification. We add Rotational media(RMEDIA) basic support to nvme target. Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> --- changelog of PATCH RFC v2 - change 'bdev_nonrot(ns->bdev)' to '!bdev_nonrot(ns->bdev)' based on comment. - add some support for 'nvme cmdset-ind-id-ns' drivers/nvme/target/admin-cmd.c | 42 +++++++++++++++++++++++++++++++ drivers/nvme/target/core.c | 2 ++ drivers/nvme/target/io-cmd-bdev.c | 1 + drivers/nvme/target/nvmet.h | 1 + 4 files changed, 46 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index f7e1156ac7ec..20a28102f8a0 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -489,6 +489,45 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) nvmet_req_complete(req, status); } +static void nvmet_execute_identify_indep(struct nvmet_req *req) +{ + struct nvme_id_ns_cs_indep *id; + u16 status; + + id = kzalloc(sizeof(*id), GFP_KERNEL); + if (!id) { + status = NVME_SC_INTERNAL; + goto out; + } + + /* + * Our namespace might always be shared. Not just with other + * controllers, but also with any other user of the block device. + */ + id->nmic |= NVME_NS_NMIC_SHARED; + + id->nstat |= NVME_NSTAT_NRDY; + + if (!req->ns){ + goto done; + } + + id->anagrpid = cpu_to_le32(req->ns->anagrpid); + + if (req->ns->readonly) + id->nsattr |= NVME_NS_ATTR_RO; + + if (req->ns->rotational) + id->nsfeat |= NVME_INDEP_NS_FEAT_RMEDIA; + +done: + if (!status) + status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); + kfree(id); +out: + nvmet_req_complete(req, status); +} + static void nvmet_execute_identify_ns(struct nvmet_req *req) { struct nvme_id_ns *id; @@ -706,6 +745,9 @@ static void nvmet_execute_identify(struct nvmet_req *req) break; } break; + case NVME_ID_CNS_NS_CS_INDEP: + nvmet_execute_identify_indep(req); + return; case NVME_ID_CNS_CS_CTRL: switch (req->cmd->identify.csi) { case NVME_CSI_NVM: diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index ed2424f8a396..2790fedb593b 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -1254,6 +1254,8 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl) else ctrl->cap |= ctrl->port->max_queue_size - 1; + ctrl->cap |= NVME_CAP_CRMS_CRIMS; + if (nvmet_is_passthru_subsys(ctrl->subsys)) nvmet_passthrough_override_cap(ctrl); } diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index 0bda83d0fc3e..d15ad1a864bc 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -104,6 +104,7 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns) ns->pi_type = 0; ns->metadata_size = 0; + ns->rotational = !bdev_nonrot(ns->bdev); if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY)) nvmet_bdev_ns_enable_integrity(ns); diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 190f55e6d753..86eeeadf3787 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -62,6 +62,7 @@ struct nvmet_ns { struct block_device *bdev; struct file *file; bool readonly; + bool rotational; u32 nsid; u32 blksize_shift; loff_t size; -- 2.36.2 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH RFC v3] nvmet: basic RMEDIA support for target 2024-08-06 0:49 ` [PATCH RFC] nvmet: basic RMEDIA support for target Wang Yugui 2024-08-06 8:11 ` Sagi Grimberg 2024-08-06 9:42 ` [PATCH RFC v2] " Wang Yugui @ 2024-08-06 12:40 ` Wang Yugui 2024-08-07 12:14 ` Sagi Grimberg 2 siblings, 1 reply; 15+ messages in thread From: Wang Yugui @ 2024-08-06 12:40 UTC (permalink / raw) To: linux-nvme; +Cc: Wang Yugui Rotational media(RMEDIA) support is added to the NVMe 2.0 specification. We add Rotational media(RMEDIA) basic support to nvme target. Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> --- changelog of PATCH RFC v3 - restore the process nvmet_req_find_ns() dropped in v2 changelog of PATCH RFC v2 - change 'bdev_nonrot(ns->bdev)' to '!bdev_nonrot(ns->bdev)' based on comment. - add some support for 'nvme cmdset-ind-id-ns' drivers/nvme/target/admin-cmd.c | 42 +++++++++++++++++++++++++++++++ drivers/nvme/target/core.c | 2 ++ drivers/nvme/target/io-cmd-bdev.c | 1 + drivers/nvme/target/nvmet.h | 1 + 4 files changed, 55 insertions(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index f7e1156ac7ec..20a28102f8a0 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -489,6 +489,54 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) nvmet_req_complete(req, status); } +static void nvmet_execute_identify_indep(struct nvmet_req *req) +{ + struct nvme_id_ns_cs_indep *id; + u16 status; + + id = kzalloc(sizeof(*id), GFP_KERNEL); + if (!id) { + status = NVME_SC_INTERNAL; + goto out; + } + + /* + * Our namespace might always be shared. Not just with other + * controllers, but also with any other user of the block device. + */ + id->nmic |= NVME_NS_NMIC_SHARED; + + id->nstat |= NVME_NSTAT_NRDY; + + /* return an all zeroed buffer if we can't find an active namespace */ + status = nvmet_req_find_ns(req); + if (status) { + status = 0; + goto done; + } + + if (nvmet_ns_revalidate(req->ns)) { + mutex_lock(&req->ns->subsys->lock); + nvmet_ns_changed(req->ns->subsys, req->ns->nsid); + mutex_unlock(&req->ns->subsys->lock); + } + + id->anagrpid = cpu_to_le32(req->ns->anagrpid); + + if (req->ns->readonly) + id->nsattr |= NVME_NS_ATTR_RO; + + if (req->ns->rotational) + id->nsfeat |= NVME_INDEP_NS_FEAT_RMEDIA; + +done: + if (!status) + status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); + kfree(id); +out: + nvmet_req_complete(req, status); +} + static void nvmet_execute_identify_ns(struct nvmet_req *req) { struct nvme_id_ns *id; @@ -706,6 +745,9 @@ static void nvmet_execute_identify(struct nvmet_req *req) break; } break; + case NVME_ID_CNS_NS_CS_INDEP: + nvmet_execute_identify_indep(req); + return; case NVME_ID_CNS_CS_CTRL: switch (req->cmd->identify.csi) { case NVME_CSI_NVM: diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index ed2424f8a396..2790fedb593b 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -1254,6 +1254,8 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl) else ctrl->cap |= ctrl->port->max_queue_size - 1; + ctrl->cap |= NVME_CAP_CRMS_CRIMS; + if (nvmet_is_passthru_subsys(ctrl->subsys)) nvmet_passthrough_override_cap(ctrl); } diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index 0bda83d0fc3e..d15ad1a864bc 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -104,6 +104,7 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns) ns->pi_type = 0; ns->metadata_size = 0; + ns->rotational = !bdev_nonrot(ns->bdev); if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY)) nvmet_bdev_ns_enable_integrity(ns); diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h index 190f55e6d753..86eeeadf3787 100644 --- a/drivers/nvme/target/nvmet.h +++ b/drivers/nvme/target/nvmet.h @@ -62,6 +62,7 @@ struct nvmet_ns { struct block_device *bdev; struct file *file; bool readonly; + bool rotational; u32 nsid; u32 blksize_shift; loff_t size; -- 2.36.2 ^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH RFC v3] nvmet: basic RMEDIA support for target 2024-08-06 12:40 ` [PATCH RFC v3] " Wang Yugui @ 2024-08-07 12:14 ` Sagi Grimberg 0 siblings, 0 replies; 15+ messages in thread From: Sagi Grimberg @ 2024-08-07 12:14 UTC (permalink / raw) To: Wang Yugui, linux-nvme On 06/08/2024 15:40, Wang Yugui wrote: > Rotational media(RMEDIA) support is added to the NVMe 2.0 specification. > We add Rotational media(RMEDIA) basic support to nvme target. > > Signed-off-by: Wang Yugui <wangyugui@e16-tech.com> > --- > changelog of PATCH RFC v3 > - restore the process nvmet_req_find_ns() dropped in v2 > changelog of PATCH RFC v2 > - change 'bdev_nonrot(ns->bdev)' to '!bdev_nonrot(ns->bdev)' based on comment. > - add some support for 'nvme cmdset-ind-id-ns' > > drivers/nvme/target/admin-cmd.c | 42 +++++++++++++++++++++++++++++++ > drivers/nvme/target/core.c | 2 ++ > drivers/nvme/target/io-cmd-bdev.c | 1 + > drivers/nvme/target/nvmet.h | 1 + > 4 files changed, 55 insertions(+) > > diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c > index f7e1156ac7ec..20a28102f8a0 100644 > --- a/drivers/nvme/target/admin-cmd.c > +++ b/drivers/nvme/target/admin-cmd.c > @@ -489,6 +489,54 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) > nvmet_req_complete(req, status); > } > > +static void nvmet_execute_identify_indep(struct nvmet_req *req) > +{ > + struct nvme_id_ns_cs_indep *id; > + u16 status; > + > + id = kzalloc(sizeof(*id), GFP_KERNEL); > + if (!id) { > + status = NVME_SC_INTERNAL; > + goto out; > + } > + > + /* > + * Our namespace might always be shared. Not just with other > + * controllers, but also with any other user of the block device. > + */ Non useful comment. especially the other users part... > + id->nmic |= NVME_NS_NMIC_SHARED; > + unneeded newline. > + id->nstat |= NVME_NSTAT_NRDY; > + > + /* return an all zeroed buffer if we can't find an active namespace */ > + status = nvmet_req_find_ns(req); > + if (status) { > + status = 0; > + goto done; > + } I think this should move up to be first... > + > + if (nvmet_ns_revalidate(req->ns)) { > + mutex_lock(&req->ns->subsys->lock); > + nvmet_ns_changed(req->ns->subsys, req->ns->nsid); > + mutex_unlock(&req->ns->subsys->lock); > + } This should move down to be last. > + > + id->anagrpid = cpu_to_le32(req->ns->anagrpid); > + > + if (req->ns->readonly) > + id->nsattr |= NVME_NS_ATTR_RO; > + > + if (req->ns->rotational) > + id->nsfeat |= NVME_INDEP_NS_FEAT_RMEDIA; > + > +done: > + if (!status) > + status = nvmet_copy_to_sgl(req, 0, id, sizeof(*id)); > + kfree(id); > +out: > + nvmet_req_complete(req, status); > +} > + > static void nvmet_execute_identify_ns(struct nvmet_req *req) > { > struct nvme_id_ns *id; > @@ -706,6 +745,9 @@ static void nvmet_execute_identify(struct nvmet_req *req) > break; > } > break; > + case NVME_ID_CNS_NS_CS_INDEP: > + nvmet_execute_identify_indep(req); > + return; > case NVME_ID_CNS_CS_CTRL: > switch (req->cmd->identify.csi) { > case NVME_CSI_NVM: > diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c > index ed2424f8a396..2790fedb593b 100644 > --- a/drivers/nvme/target/core.c > +++ b/drivers/nvme/target/core.c > @@ -1254,6 +1254,8 @@ static void nvmet_init_cap(struct nvmet_ctrl *ctrl) > else > ctrl->cap |= ctrl->port->max_queue_size - 1; > > + ctrl->cap |= NVME_CAP_CRMS_CRIMS; > + > if (nvmet_is_passthru_subsys(ctrl->subsys)) > nvmet_passthrough_override_cap(ctrl); > } > diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c > index 0bda83d0fc3e..d15ad1a864bc 100644 > --- a/drivers/nvme/target/io-cmd-bdev.c > +++ b/drivers/nvme/target/io-cmd-bdev.c > @@ -104,6 +104,7 @@ int nvmet_bdev_ns_enable(struct nvmet_ns *ns) > > ns->pi_type = 0; > ns->metadata_size = 0; > + ns->rotational = !bdev_nonrot(ns->bdev); > if (IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY)) > nvmet_bdev_ns_enable_integrity(ns); > > diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h > index 190f55e6d753..86eeeadf3787 100644 > --- a/drivers/nvme/target/nvmet.h > +++ b/drivers/nvme/target/nvmet.h > @@ -62,6 +62,7 @@ struct nvmet_ns { > struct block_device *bdev; > struct file *file; > bool readonly; > + bool rotational; > u32 nsid; > u32 blksize_shift; > loff_t size; ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2024-08-12 14:28 UTC | newest] Thread overview: 15+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-07-23 23:24 [PATCH RFC] basic RMEDIA support for nvme host Wang Yugui 2024-07-24 12:30 ` [PATCH RFC v2] nvme: basic RMEDIA support for host Wang Yugui 2024-07-25 0:43 ` Damien Le Moal 2024-07-25 1:56 ` Wang Yugui 2024-07-25 14:10 ` Christoph Hellwig 2024-07-25 22:59 ` Damien Le Moal 2024-08-12 14:28 ` Hannes Reinecke 2024-07-25 14:09 ` Christoph Hellwig 2024-08-06 0:48 ` [PATCH RFC v3] " Wang Yugui 2024-08-06 0:49 ` [PATCH RFC] nvmet: basic RMEDIA support for target Wang Yugui 2024-08-06 8:11 ` Sagi Grimberg 2024-08-06 9:08 ` Wang Yugui 2024-08-06 9:42 ` [PATCH RFC v2] " Wang Yugui 2024-08-06 12:40 ` [PATCH RFC v3] " Wang Yugui 2024-08-07 12:14 ` Sagi Grimberg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox