[PATCH] nvme: Fix zns drives without append support to export correct permissions

Damien Le Moal damien.lemoal at opensource.wdc.com
Sat Mar 12 00:14:56 PST 2022


On 3/12/22 05:16, Pankaj Raghav wrote:
> This commit 2f4c9ba23b88 ("nvme: export zoned namespaces without Zone
> Append support read-only") exported zoned namespaces without append support
> to be marked as ro. It does it by setting NVME_NS_FORCE_RO to the
> ns->flags in nvme_update_zone_info and later nvme_update_disk_info will
> check for this flag and set the disk as ro.
> 
> But later this commit 73d90386b559 ("nvme: cleanup zone information
> initialization") rearranged nvme_update_disk_info to be called before
> nvme_update_zone_info thereby not marking the disk as ro. The call order
> cannot be just reverted because nvme_update_zone_info sets certain queue
> parameters such as zone_write_granularity that depend on the prior call
> to nvme_update_disk_info.
> 
> Call nvme_update_disk_info after nvme_update_zone_info again so that the
> permission for ZNS drives are marked correctly.
> 
> Fixes: 73d90386b559 ("nvme: cleanup zone information initialization")
> Signed-off-by: Pankaj Raghav <p.raghav at samsung.com>
> ---
>  drivers/nvme/host/core.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 51c08f206cbf..67a78653b07c 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1913,6 +1913,11 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
>  		ret = nvme_update_zone_info(ns, lbaf);
>  		if (ret)
>  			goto out_unfreeze;
> +		/* nvme_update_zone_info might set the namespace to be marked
> +		 * as read-only. Call nvme_update_disk_info so that the disk
> +		 * is updated with the appropriate permission.
> +		 */

Multi-line comment block should start with a "/*" line without text.

> +		nvme_update_disk_info(ns->disk, ns, id);

It may make more sense to move the "set_disk_ro()" call at the end of
nvme_update_zone_info() into a different helper (say
nvme_set_disk_mode()) and call that new helper here to avoid going
through again all the settings that nvme_update_disk_info() does.

>  	}
>  
>  	set_bit(NVME_NS_READY, &ns->flags);


-- 
Damien Le Moal
Western Digital Research



More information about the Linux-nvme mailing list