[PATCH] nvme: enable ro namespace for ZNS without append

Christoph Hellwig hch at lst.de
Fri Nov 6 09:14:28 EST 2020


> +#ifdef CONFIG_BLK_DEV_ZONED
> +	if (blk_queue_is_zoned(disk->queue) && !ns->zoned_ns_supp)
> +		set_disk_ro(disk, true);
> +#endif

I think we can simplify this at bit.  Add a new NVME_NS_FORCE_RO flag
to ns->flags, set it in nvme_update_zone_info, and just query it here
without any ifdefs.

>  	struct request_queue *q = disk->queue;
>  	struct nvme_command c = { };
>  	struct nvme_id_ns_zns *id;
> +	bool zoned_ns_supp = true;
>  	int status;
>  
>  	/* Driver requires zone append support */
>  	if (!(le32_to_cpu(log->iocs[nvme_cmd_zone_append]) &
>  			NVME_CMD_EFFECTS_CSUPP)) {
> +		zoned_ns_supp = false;
>  		dev_warn(ns->ctrl->device,
>  			"append not supported for zoned namespace:%d\n",
>  			ns->head->ns_id);
> +	} else {
> +		/* Lazily query controller append limit for the first
> +		 * zoned namespace
> +		 */
> +		if (!ns->ctrl->max_zone_append) {
> +			status = nvme_set_max_append(ns->ctrl);
> +			if (status)
> +				return status;
> +		}

While you're at it:  my inverse the polarity of the if check as that reads just
a little more natural, and maybe mention in the warning that the namespace is
forced to read-only mode?

Otherwise this looks good.



More information about the Linux-nvme mailing list