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

Christoph Hellwig hch at lst.de
Wed Mar 16 03:50:16 PDT 2022


On Wed, Mar 16, 2022 at 10:34:23AM +0100, Pankaj Raghav wrote:
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 51c08f206cbf..cde33f2a3a5a 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1855,8 +1855,7 @@ static void nvme_update_disk_info(struct gendisk *disk,
>  	blk_queue_max_write_zeroes_sectors(disk->queue,
>  					   ns->ctrl->max_zeroes_sectors);
>  
> -	set_disk_ro(disk, (id->nsattr & NVME_NS_ATTR_RO) ||
> -		test_bit(NVME_NS_FORCE_RO, &ns->flags));
> +	set_disk_ro(disk, (id->nsattr & NVME_NS_ATTR_RO));

This will now set a namespace that was read-only due to unsupported ZNS
features writable during revalidation.

>   * Fill in the status and result information from the CQE, and then figure out
>   * if blk-mq will need to use IPI magic to complete the request, and if yes do
> diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
> index 9f81beb4df4e..4ab685fa02b4 100644
> --- a/drivers/nvme/host/zns.c
> +++ b/drivers/nvme/host/zns.c
> @@ -113,6 +113,7 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
>  	blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q);
>  	blk_queue_max_open_zones(q, le32_to_cpu(id->mor) + 1);
>  	blk_queue_max_active_zones(q, le32_to_cpu(id->mar) + 1);
> +	nvme_set_disk_mode_ro(ns);

And this will set a disk that is read-only due to NVME_NS_ATTR_RO
writable if the controller supports all essential ZNS features.



More information about the Linux-nvme mailing list