* [PATCH v3] nvme: Fix zns drives without append support to export correct permissions
[not found] <CGME20220322092053eucas1p16f2311a54b7c82c47352fca5db6277e6@eucas1p1.samsung.com>
@ 2022-03-22 9:20 ` Pankaj Raghav
2022-03-23 8:20 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Pankaj Raghav @ 2022-03-22 9:20 UTC (permalink / raw)
To: Javier González, Keith Busch, Christoph Hellwig,
Sagi Grimberg, Damien Le Moal, Jens Axboe
Cc: Luis Chamberlain, Adam Manzanares, kanchan Joshi,
Johannes Thumshirn, Pankaj Raghav, Kanchan Joshi, linux-nvme,
Pankaj Raghav
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.
Remove the call to set_disk_ro in nvme_update_disk_info.
Call set_disk_ro after nvme_update_zone_info and nvme_update_disk_info
to set the permission for ZNS drives correctly. The same applies to the
multipath disk path.
Fixes: 73d90386b559 ("nvme: cleanup zone information initialization")
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
Changes since v1:
- Add a new helper to set permission directly from nvme_update_zone_info
instead of calling nvme_update_disk_info again (Damien)
Changes since v2
- Adding a new call to set_disk_ro in nvme_update_zone_info will create
a race window, and set the disk to write if all Zone requirements are
satisfied even when id->nsattr has ro bit set. Call set_disk_ro
directly after the calls to nvme_update_disk_info and
nvme_update_zone_info to avoid incorrect behaviour. (Christoph)
- Open code the call to set_disk_ro as there are no other
users(Chaitanya and Christoph)
drivers/nvme/host/core.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 677fa4bf76d3..75c9c4fa9049 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1830,9 +1830,6 @@ static void nvme_update_disk_info(struct gendisk *disk,
nvme_config_discard(disk, ns);
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));
}
static inline bool nvme_first_scan(struct gendisk *disk)
@@ -1891,6 +1888,8 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
goto out_unfreeze;
}
+ set_disk_ro(ns->disk, (id->nsattr & NVME_NS_ATTR_RO) ||
+ test_bit(NVME_NS_FORCE_RO, &ns->flags));
set_bit(NVME_NS_READY, &ns->flags);
blk_mq_unfreeze_queue(ns->disk->queue);
@@ -1903,6 +1902,9 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
if (nvme_ns_head_multipath(ns->head)) {
blk_mq_freeze_queue(ns->head->disk->queue);
nvme_update_disk_info(ns->head->disk, ns, id);
+ set_disk_ro(ns->head->disk,
+ (id->nsattr & NVME_NS_ATTR_RO) ||
+ test_bit(NVME_NS_FORCE_RO, &ns->flags));
nvme_mpath_revalidate_paths(ns);
blk_stack_limits(&ns->head->disk->queue->limits,
&ns->queue->limits, 0);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] nvme: Fix zns drives without append support to export correct permissions
2022-03-22 9:20 ` [PATCH v3] nvme: Fix zns drives without append support to export correct permissions Pankaj Raghav
@ 2022-03-23 8:20 ` Christoph Hellwig
2022-03-23 8:26 ` Pankaj Raghav
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2022-03-23 8:20 UTC (permalink / raw)
To: Pankaj Raghav
Cc: Javier González, Keith Busch, Christoph Hellwig,
Sagi Grimberg, Damien Le Moal, Jens Axboe, Luis Chamberlain,
Adam Manzanares, kanchan Joshi, Johannes Thumshirn, Pankaj Raghav,
Kanchan Joshi, linux-nvme
Thanks,
applied to nvme-5.18.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] nvme: Fix zns drives without append support to export correct permissions
2022-03-23 8:20 ` Christoph Hellwig
@ 2022-03-23 8:26 ` Pankaj Raghav
0 siblings, 0 replies; 3+ messages in thread
From: Pankaj Raghav @ 2022-03-23 8:26 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Javier González, Keith Busch, Sagi Grimberg, Damien Le Moal,
Jens Axboe, Luis Chamberlain, Adam Manzanares, kanchan Joshi,
Johannes Thumshirn, Pankaj Raghav, Kanchan Joshi, linux-nvme
Thanks Christoph!
On 2022-03-23 09:20, Christoph Hellwig wrote:
> Thanks,
>
> applied to nvme-5.18.
--
Regards,
Pankaj
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-23 8:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20220322092053eucas1p16f2311a54b7c82c47352fca5db6277e6@eucas1p1.samsung.com>
2022-03-22 9:20 ` [PATCH v3] nvme: Fix zns drives without append support to export correct permissions Pankaj Raghav
2022-03-23 8:20 ` Christoph Hellwig
2022-03-23 8:26 ` Pankaj Raghav
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox