diff mbox series

[1/3] dm: move setting zoned_enabled to dm_table_set_restrictions

Message ID 20240524142929.817565-2-hch@lst.de (mailing list archive)
State New
Headers show
Series [1/3] dm: move setting zoned_enabled to dm_table_set_restrictions | expand

Commit Message

Christoph Hellwig May 24, 2024, 2:29 p.m. UTC
Keep it together with the rest of the zoned code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/dm-table.c | 3 ---
 drivers/md/dm-zone.c  | 8 +++++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

Comments

Mike Snitzer May 24, 2024, 3:07 p.m. UTC | #1
On Fri, May 24, 2024 at 04:29:09PM +0200, Christoph Hellwig wrote:
> Keep it together with the rest of the zoned code.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/md/dm-table.c | 3 ---
>  drivers/md/dm-zone.c  | 8 +++++++-
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index cc66a27c363a65..e291b78b307b13 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -2040,9 +2040,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
>  		r = dm_set_zones_restrictions(t, q);
>  		if (r)
>  			return r;
> -		if (blk_queue_is_zoned(q) &&
> -		    !static_key_enabled(&zoned_enabled.key))
> -			static_branch_enable(&zoned_enabled);
>  	}
>  
>  	dm_update_crypto_profile(q, t);
> diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
> index 8e6bcb0d786a1a..eb1165324ab047 100644
> --- a/drivers/md/dm-zone.c
> +++ b/drivers/md/dm-zone.c
> @@ -287,7 +287,13 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
>  		       queue_emulates_zone_append(q) ? "emulated" : "native");
>  	}
>  
> -	return dm_revalidate_zones(md, t);
> +	ret = dm_revalidate_zones(md, t);
> +	if (ret < 0)
> +		return 0;

Not following why you're return 0 if r < 0.

blk_revalidate_disk_zones() has quite a few negative checks that
return regular error codes, so why drop those validation errors?

> +
> +	if (!static_key_enabled(&zoned_enabled.key))
> +		static_branch_enable(&zoned_enabled);
> +	return 0;
>  }
>  
>  /*
> -- 
> 2.43.0
>
Christoph Hellwig May 24, 2024, 4:40 p.m. UTC | #2
On Fri, May 24, 2024 at 11:07:59AM -0400, Mike Snitzer wrote:
> > +	ret = dm_revalidate_zones(md, t);
> > +	if (ret < 0)
> > +		return 0;
> 
> Not following why you're return 0 if r < 0.
> 
> blk_revalidate_disk_zones() has quite a few negative checks that
> return regular error codes, so why drop those validation errors?

Because I messed this up..
diff mbox series

Patch

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index cc66a27c363a65..e291b78b307b13 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -2040,9 +2040,6 @@  int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 		r = dm_set_zones_restrictions(t, q);
 		if (r)
 			return r;
-		if (blk_queue_is_zoned(q) &&
-		    !static_key_enabled(&zoned_enabled.key))
-			static_branch_enable(&zoned_enabled);
 	}
 
 	dm_update_crypto_profile(q, t);
diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c
index 8e6bcb0d786a1a..eb1165324ab047 100644
--- a/drivers/md/dm-zone.c
+++ b/drivers/md/dm-zone.c
@@ -287,7 +287,13 @@  int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
 		       queue_emulates_zone_append(q) ? "emulated" : "native");
 	}
 
-	return dm_revalidate_zones(md, t);
+	ret = dm_revalidate_zones(md, t);
+	if (ret < 0)
+		return 0;
+
+	if (!static_key_enabled(&zoned_enabled.key))
+		static_branch_enable(&zoned_enabled);
+	return 0;
 }
 
 /*