All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] nvme: enable ro namespace for ZNS without append
@ 2020-11-10  9:39 ` Javier González
  0 siblings, 0 replies; 14+ messages in thread
From: Javier González @ 2020-11-10  9:39 UTC (permalink / raw)
  To: linux-nvme
  Cc: linux-block, hch, kbusch, sagi, axboe, joshi.k, k.jensen,
	Niklas.Cassel, Javier González

Allow ZNS NVMe SSDs to present a read-only namespace when append is not
supported, instead of rejecting the namespace directly.

This allows (i) the namespace to be used in read-only mode, which is not
a problem as the append command only affects the write path, and (ii) to
use standard management tools such as nvme-cli to choose a different
format or firmware slot that is compatible with the Linux zoned block
device.

This patch includes comments from Christoph, Niklas and Keith that
applied to a different approach setting capacity to 0
  https://www.spinics.net/lists/linux-block/msg60747.html

The reminder of the original patch will be submitted separately.

Changes since V1:
  - Change logic to use NVME_NS_ATTR_RO (from Christoph)
  - Set max_zone_append egen in RO. This allows the device to be properly
    revalidated and enables user-space tools such as blkzone to be used when
    interacting with this zoned device.

Signed-off-by: Javier González <javier.gonz@samsung.com>
---
 drivers/nvme/host/core.c | 3 ++-
 drivers/nvme/host/nvme.h | 1 +
 drivers/nvme/host/zns.c  | 4 ++--
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 40ca71b29bb9..4fcaec0b330b 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2058,7 +2058,8 @@ static void nvme_update_disk_info(struct gendisk *disk,
 	nvme_config_discard(disk, ns);
 	nvme_config_write_zeroes(disk, ns);
 
-	if (id->nsattr & NVME_NS_ATTR_RO)
+	if (id->nsattr & NVME_NS_ATTR_RO ||
+			test_bit(NVME_NS_FORCE_RO, &ns->flags))
 		set_disk_ro(disk, true);
 	else
 		set_disk_ro(disk, false);
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index bc330bf0d3bd..3a985e98ca27 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -448,6 +448,7 @@ struct nvme_ns {
 #define NVME_NS_REMOVING	0
 #define NVME_NS_DEAD     	1
 #define NVME_NS_ANA_PENDING	2
+#define NVME_NS_FORCE_RO	3
 
 	struct nvme_fault_inject fault_inject;
 
diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c
index 67e87e9f306f..8f3632c4db05 100644
--- a/drivers/nvme/host/zns.c
+++ b/drivers/nvme/host/zns.c
@@ -57,10 +57,10 @@ int nvme_update_zone_info(struct nvme_ns *ns, unsigned lbaf)
 	/* Driver requires zone append support */
 	if (!(le32_to_cpu(log->iocs[nvme_cmd_zone_append]) &
 			NVME_CMD_EFFECTS_CSUPP)) {
+		set_bit(NVME_NS_FORCE_RO, &ns->flags);
 		dev_warn(ns->ctrl->device,
-			"append not supported for zoned namespace:%d\n",
+			"append not supported for zoned namespace:%d. Forcing to read-only mode\n",
 			ns->head->ns_id);
-		return -EINVAL;
 	}
 
 	/* Lazily query controller append limit for the first zoned namespace */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-11-10 19:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10  9:39 [PATCH V2] nvme: enable ro namespace for ZNS without append Javier González
2020-11-10  9:39 ` Javier González
2020-11-10  9:43 ` Christoph Hellwig
2020-11-10  9:43   ` Christoph Hellwig
2020-11-10 10:15   ` Javier González
2020-11-10 10:15     ` Javier González
2020-11-10 11:25   ` [PATCH V2] " Niklas Cassel
2020-11-10 11:25     ` Niklas Cassel
2020-11-10 19:55     ` Javier González
2020-11-10 19:55       ` Javier González
2020-11-10 14:16 ` [PATCH V2] " Keith Busch
2020-11-10 14:16   ` Keith Busch
2020-11-10 15:53   ` Javier González
2020-11-10 15:53     ` Javier González

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.