linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcache: only check feature sets when sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES
@ 2021-01-28 10:48 Coly Li
  2021-01-28 10:57 ` Coly Li
  2021-01-28 14:35 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Coly Li @ 2021-01-28 10:48 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, Coly Li, stable, Bockholdt Arne

For super block version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES, it
doesn't make sense to check the feature sets. This patch checks
super block version in bch_has_feature_* routines, if the version
doesn't have feature sets yet, returns 0 (false) to the caller.

Fixes: 5342fd425502 ("bcache: set bcache device into read-only mode for BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET") 
Fixes: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
Cc: stable@vger.kernel.org # 5.9+
Reported-and-tested-by: Bockholdt Arne <a.bockholdt@precitec-optronik.de>
Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/features.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/md/bcache/features.h b/drivers/md/bcache/features.h
index 84fc2c0f0101..d1c8fd3977fc 100644
--- a/drivers/md/bcache/features.h
+++ b/drivers/md/bcache/features.h
@@ -33,6 +33,8 @@
 #define BCH_FEATURE_COMPAT_FUNCS(name, flagname) \
 static inline int bch_has_feature_##name(struct cache_sb *sb) \
 { \
+	if (sb->version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES) \
+		return 0; \
 	return (((sb)->feature_compat & \
 		BCH##_FEATURE_COMPAT_##flagname) != 0); \
 } \
@@ -50,6 +52,8 @@ static inline void bch_clear_feature_##name(struct cache_sb *sb) \
 #define BCH_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
 static inline int bch_has_feature_##name(struct cache_sb *sb) \
 { \
+	if (sb->version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES) \
+		return 0; \
 	return (((sb)->feature_ro_compat & \
 		BCH##_FEATURE_RO_COMPAT_##flagname) != 0); \
 } \
@@ -67,6 +71,8 @@ static inline void bch_clear_feature_##name(struct cache_sb *sb) \
 #define BCH_FEATURE_INCOMPAT_FUNCS(name, flagname) \
 static inline int bch_has_feature_##name(struct cache_sb *sb) \
 { \
+	if (sb->version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES) \
+		return 0; \
 	return (((sb)->feature_incompat & \
 		BCH##_FEATURE_INCOMPAT_##flagname) != 0); \
 } \
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bcache: only check feature sets when sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES
  2021-01-28 10:48 [PATCH] bcache: only check feature sets when sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES Coly Li
@ 2021-01-28 10:57 ` Coly Li
  2021-01-28 14:35 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Coly Li @ 2021-01-28 10:57 UTC (permalink / raw)
  To: axboe; +Cc: linux-bcache, linux-block, stable, Bockholdt Arne

On 1/28/21 6:48 PM, Coly Li wrote:
> For super block version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES, it
> doesn't make sense to check the feature sets. This patch checks
> super block version in bch_has_feature_* routines, if the version
> doesn't have feature sets yet, returns 0 (false) to the caller.
> 
> Fixes: 5342fd425502 ("bcache: set bcache device into read-only mode for BCH_FEATURE_INCOMPAT_OBSO_LARGE_BUCKET") 
> Fixes: ffa470327572 ("bcache: add bucket_size_hi into struct cache_sb_disk for large bucket")
> Cc: stable@vger.kernel.org # 5.9+
> Reported-and-tested-by: Bockholdt Arne <a.bockholdt@precitec-optronik.de>
> Signed-off-by: Coly Li <colyli@suse.de>

Hi Jens,

Please take this patch for v5.11-rc6, this is necessary to go with other
fixes in previous wave.

Thank you in advance.

Coly Li


> ---
>  drivers/md/bcache/features.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/md/bcache/features.h b/drivers/md/bcache/features.h
> index 84fc2c0f0101..d1c8fd3977fc 100644
> --- a/drivers/md/bcache/features.h
> +++ b/drivers/md/bcache/features.h
> @@ -33,6 +33,8 @@
>  #define BCH_FEATURE_COMPAT_FUNCS(name, flagname) \
>  static inline int bch_has_feature_##name(struct cache_sb *sb) \
>  { \
> +	if (sb->version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES) \
> +		return 0; \
>  	return (((sb)->feature_compat & \
>  		BCH##_FEATURE_COMPAT_##flagname) != 0); \
>  } \
> @@ -50,6 +52,8 @@ static inline void bch_clear_feature_##name(struct cache_sb *sb) \
>  #define BCH_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
>  static inline int bch_has_feature_##name(struct cache_sb *sb) \
>  { \
> +	if (sb->version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES) \
> +		return 0; \
>  	return (((sb)->feature_ro_compat & \
>  		BCH##_FEATURE_RO_COMPAT_##flagname) != 0); \
>  } \
> @@ -67,6 +71,8 @@ static inline void bch_clear_feature_##name(struct cache_sb *sb) \
>  #define BCH_FEATURE_INCOMPAT_FUNCS(name, flagname) \
>  static inline int bch_has_feature_##name(struct cache_sb *sb) \
>  { \
> +	if (sb->version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES) \
> +		return 0; \
>  	return (((sb)->feature_incompat & \
>  		BCH##_FEATURE_INCOMPAT_##flagname) != 0); \
>  } \
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bcache: only check feature sets when sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES
  2021-01-28 10:48 [PATCH] bcache: only check feature sets when sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES Coly Li
  2021-01-28 10:57 ` Coly Li
@ 2021-01-28 14:35 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-01-28 14:35 UTC (permalink / raw)
  To: Coly Li; +Cc: linux-bcache, linux-block, stable, Bockholdt Arne

On 1/28/21 3:48 AM, Coly Li wrote:
> For super block version < BCACHE_SB_VERSION_CDEV_WITH_FEATURES, it
> doesn't make sense to check the feature sets. This patch checks
> super block version in bch_has_feature_* routines, if the version
> doesn't have feature sets yet, returns 0 (false) to the caller.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-28 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28 10:48 [PATCH] bcache: only check feature sets when sb->version >= BCACHE_SB_VERSION_CDEV_WITH_FEATURES Coly Li
2021-01-28 10:57 ` Coly Li
2021-01-28 14:35 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).