diff mbox series

[3/4] nvme: allow revalidate to set a namespace read-only

Message ID 20201129181926.897775-4-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/4] block: add a hard-readonly flag to struct gendisk | expand

Commit Message

Christoph Hellwig Nov. 29, 2020, 6:19 p.m. UTC
Unconditionally call set_disk_ro now that it only updates the hardware
state.  This allows to properly set up the Linux devices read-only when
the controller turns a previously writable namespace read-only.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/nvme/host/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Chaitanya Kulkarni Nov. 29, 2020, 9:13 p.m. UTC | #1
On 11/29/20 10:22, Christoph Hellwig wrote:
> Unconditionally call set_disk_ro now that it only updates the hardware
> state.  This allows to properly set up the Linux devices read-only when
> the controller turns a previously writable namespace read-only.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks good.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Hannes Reinecke Nov. 30, 2020, 7:57 a.m. UTC | #2
On 11/29/20 7:19 PM, Christoph Hellwig wrote:
> Unconditionally call set_disk_ro now that it only updates the hardware
> state.  This allows to properly set up the Linux devices read-only when
> the controller turns a previously writable namespace read-only.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   drivers/nvme/host/core.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index bc89e8659c403f..2442f43a1a5624 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2047,8 +2047,7 @@  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)
-		set_disk_ro(disk, true);
+	set_disk_ro(disk, id->nsattr & NVME_NS_ATTR_RO);
 }
 
 static inline bool nvme_first_scan(struct gendisk *disk)