diff mbox series

[2/9] block: cleanup the !zoned case in blk_revalidate_disk_zones

Message ID 20191108015702.233102-3-damien.lemoal@wdc.com (mailing list archive)
State New, archived
Headers show
Series Zoned block device enhancements and zone report rework | expand

Commit Message

Damien Le Moal Nov. 8, 2019, 1:56 a.m. UTC
From: Christoph Hellwig <hch@lst.de>

blk_revalidate_disk_zones is never called for non-zoned devices.  Just
return early and warn instead of trying to handle this case.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/blk-zoned.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Hannes Reinecke Nov. 8, 2019, 7:11 a.m. UTC | #1
On 11/8/19 2:56 AM, Damien Le Moal wrote:
> From: Christoph Hellwig <hch@lst.de>
> 
> blk_revalidate_disk_zones is never called for non-zoned devices.  Just
> return early and warn instead of trying to handle this case.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  block/blk-zoned.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index dae787f67019..523a28d7a15c 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -520,6 +520,9 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
>  	sector_t sector = 0;
>  	int ret = 0;
>  
> +	if (WARN_ON_ONCE(!blk_queue_is_zoned(q)))
> +		return -EIO;
> +
>  	/*
>  	 * BIO based queues do not use a scheduler so only q->nr_zones
>  	 * needs to be updated so that the sysfs exposed value is correct.
> @@ -535,10 +538,8 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
>  	 */
>  	noio_flag = memalloc_noio_save();
>  
> -	if (!blk_queue_is_zoned(q) || !nr_zones) {
> -		nr_zones = 0;
> +	if (!nr_zones)
>  		goto update;
> -	}
>  
>  	/* Allocate bitmaps */
>  	ret = -ENOMEM;
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Chaitanya Kulkarni Nov. 8, 2019, 6:50 p.m. UTC | #2
Looks good to me.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 11/07/2019 05:57 PM, Damien Le Moal wrote:
> From: Christoph Hellwig<hch@lst.de>
>
> blk_revalidate_disk_zones is never called for non-zoned devices.  Just
> return early and warn instead of trying to handle this case.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
> Signed-off-by: Damien Le Moal<damien.lemoal@wdc.com>
> ---
diff mbox series

Patch

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index dae787f67019..523a28d7a15c 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -520,6 +520,9 @@  int blk_revalidate_disk_zones(struct gendisk *disk)
 	sector_t sector = 0;
 	int ret = 0;
 
+	if (WARN_ON_ONCE(!blk_queue_is_zoned(q)))
+		return -EIO;
+
 	/*
 	 * BIO based queues do not use a scheduler so only q->nr_zones
 	 * needs to be updated so that the sysfs exposed value is correct.
@@ -535,10 +538,8 @@  int blk_revalidate_disk_zones(struct gendisk *disk)
 	 */
 	noio_flag = memalloc_noio_save();
 
-	if (!blk_queue_is_zoned(q) || !nr_zones) {
-		nr_zones = 0;
+	if (!nr_zones)
 		goto update;
-	}
 
 	/* Allocate bitmaps */
 	ret = -ENOMEM;