diff mbox series

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

Message ID 20210109104254.1077093-7-hch@lst.de
State New
Headers show
Series None | expand

Commit Message

Christoph Hellwig Jan. 9, 2021, 10:42 a.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>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
---
 drivers/nvme/host/core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Chaitanya Kulkarni Jan. 9, 2021, 8:27 p.m. UTC | #1
On 1/9/21 02:49, 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>
> Reviewed-by: Keith Busch <kbusch@kernel.org>
> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
> ---
>  drivers/nvme/host/core.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index ce1b6151944131..3a0557ccc9fc5d 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2114,9 +2114,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) ||
> -	    test_bit(NVME_NS_FORCE_RO, &ns->flags))
> -		set_disk_ro(disk, true);
> +	set_disk_ro(disk, (id->nsattr & NVME_NS_ATTR_RO) ||
> +		test_bit(NVME_NS_FORCE_RO, &ns->flags));
>  }
>  

If we are adding a multi-line function call can we please consider
following, on the top of this that matches earlier multi-line function
call in the same nvme_update_disk_into() :-

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3a0557ccc9fc..5cf0f801a95e 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2115,7 +2115,7 @@ static void nvme_update_disk_info(struct gendisk
*disk,
        nvme_config_write_zeroes(disk, ns);
 
        set_disk_ro(disk, (id->nsattr & NVME_NS_ATTR_RO) ||
-               test_bit(NVME_NS_FORCE_RO, &ns->flags));
+                   test_bit(NVME_NS_FORCE_RO, &ns->flags));
 }
 
static inline bool nvme_first_scan(struct gendisk *disk)

Otherwise, looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>  static inline bool nvme_first_scan(struct gendisk *disk)
Hannes Reinecke Jan. 10, 2021, 3:01 p.m. UTC | #2
On 1/9/21 11:42 AM, 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>

> Reviewed-by: Keith Busch <kbusch@kernel.org>

> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

> ---

>   drivers/nvme/host/core.c | 5 ++---

>   1 file changed, 2 insertions(+), 3 deletions(-)

> 

> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c

> index ce1b6151944131..3a0557ccc9fc5d 100644

> --- a/drivers/nvme/host/core.c

> +++ b/drivers/nvme/host/core.c

> @@ -2114,9 +2114,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) ||

> -	    test_bit(NVME_NS_FORCE_RO, &ns->flags))

> -		set_disk_ro(disk, true);

> +	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)

> 

Reviewed-by: Hannes Reinecke <hare@suse.de>


Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
diff mbox series

Patch

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ce1b6151944131..3a0557ccc9fc5d 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2114,9 +2114,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) ||
-	    test_bit(NVME_NS_FORCE_RO, &ns->flags))
-		set_disk_ro(disk, true);
+	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)