[PATCH] nvme: Fix zns drives without append support to export correct permissions
Pankaj Raghav
p.raghav at samsung.com
Mon Mar 14 03:19:52 PDT 2022
On 2022-03-14 09:44, Christoph Hellwig wrote:
> On Mon, Mar 14, 2022 at 09:36:35AM +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 creates a race window during revalidation where the zone will be
> set writable here only to be set read-only again a little later.
We call the blk_revalidate_zone after nvme_update_zone_info. So before
we revalidate, the correct permission is already set.
// sets the disk to ro based on nsattr
nvme_update_disk_info(ns->disk, ns, id);
if (ns->head->ids.csi == NVME_CSI_ZNS) {
// Sets the disk to ro based on append
ret = nvme_update_zone_info(ns, lbaf);
if (ret)
goto out_unfreeze;
}
set_bit(NVME_NS_READY, &ns->flags);
blk_mq_unfreeze_queue(ns->disk->queue);
if (blk_queue_is_zoned(ns->queue)) {
// Revalidate is called after the permission is set
ret = nvme_revalidate_zones(ns);
if (ret && !nvme_first_scan(ns->disk))
return ret;
}
Am I missing something?
--
Regards,
Pankaj
More information about the Linux-nvme
mailing list