linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcache: make checkings for sb.nr_in_set and sb.nr_this_dev to be more precise
@ 2021-11-01  3:07 Lin Feng
  2021-11-01  5:29 ` Coly Li
  0 siblings, 1 reply; 2+ messages in thread
From: Lin Feng @ 2021-11-01  3:07 UTC (permalink / raw)
  To: colyli, kent.overstreet; +Cc: linux-bcache, linux-kernel, linf

Commit 697e23495c94f0380c1ed8b11f830b92b64c99ea
("bcache: explicitly make cache_set only have single cache")
explicitly makes a cache_set only have single cache and based on the
fact that historily only one cache is ever used in the cache set, so
valid number fo sb.nr_in_set should be 1 and sb.nr_this_dev should
always be 0.

Based on above truth, codes validations for sb.nr_in_set and sb.nr_this_dev
can make to be more accurate, that means tolerance for error checking
are reduced comparing before.

Signed-off-by: Lin Feng <linf@wangsu.com>
---
 drivers/md/bcache/bcache.h | 2 +-
 drivers/md/bcache/super.c  | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index 5fc989a6d452..a4a410a178c0 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -833,7 +833,7 @@ static inline uint8_t ptr_stale(struct cache_set *c, const struct bkey *k,
 static inline bool ptr_available(struct cache_set *c, const struct bkey *k,
 				 unsigned int i)
 {
-	return (PTR_DEV(k, i) < MAX_CACHES_PER_SET) && c->cache;
+	return (PTR_DEV(k, i) == 0) && c->cache;
 }
 
 /* Btree key macros */
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index f2874c77ff79..2253044c9289 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -140,9 +140,7 @@ static const char *read_super_common(struct cache_sb *sb,  struct block_device *
 		goto err;
 
 	err = "Bad cache device number in set";
-	if (!sb->nr_in_set ||
-	    sb->nr_in_set <= sb->nr_this_dev ||
-	    sb->nr_in_set > MAX_CACHES_PER_SET)
+	if (sb->nr_in_set != 1 || sb->nr_this_dev != 0)
 		goto err;
 
 	err = "Journal buckets not sequential";
-- 
2.31.1


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

* Re: [PATCH] bcache: make checkings for sb.nr_in_set and sb.nr_this_dev to be more precise
  2021-11-01  3:07 [PATCH] bcache: make checkings for sb.nr_in_set and sb.nr_this_dev to be more precise Lin Feng
@ 2021-11-01  5:29 ` Coly Li
  0 siblings, 0 replies; 2+ messages in thread
From: Coly Li @ 2021-11-01  5:29 UTC (permalink / raw)
  To: Lin Feng; +Cc: linux-bcache, linux-kernel, kent.overstreet

On 11/1/21 11:07 AM, Lin Feng wrote:
> Commit 697e23495c94f0380c1ed8b11f830b92b64c99ea
> ("bcache: explicitly make cache_set only have single cache")
> explicitly makes a cache_set only have single cache and based on the
> fact that historily only one cache is ever used in the cache set, so
> valid number fo sb.nr_in_set should be 1 and sb.nr_this_dev should
> always be 0.
>
> Based on above truth, codes validations for sb.nr_in_set and sb.nr_this_dev
> can make to be more accurate, that means tolerance for error checking
> are reduced comparing before.
>
> Signed-off-by: Lin Feng <linf@wangsu.com>

Hi Lin,

Thanks for the patch up. I add this change to my for-test directory.

Coly Li


> ---
>   drivers/md/bcache/bcache.h | 2 +-
>   drivers/md/bcache/super.c  | 4 +---
>   2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
> index 5fc989a6d452..a4a410a178c0 100644
> --- a/drivers/md/bcache/bcache.h
> +++ b/drivers/md/bcache/bcache.h
> @@ -833,7 +833,7 @@ static inline uint8_t ptr_stale(struct cache_set *c, const struct bkey *k,
>   static inline bool ptr_available(struct cache_set *c, const struct bkey *k,
>   				 unsigned int i)
>   {
> -	return (PTR_DEV(k, i) < MAX_CACHES_PER_SET) && c->cache;
> +	return (PTR_DEV(k, i) == 0) && c->cache;
>   }
>   
>   /* Btree key macros */
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index f2874c77ff79..2253044c9289 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -140,9 +140,7 @@ static const char *read_super_common(struct cache_sb *sb,  struct block_device *
>   		goto err;
>   
>   	err = "Bad cache device number in set";
> -	if (!sb->nr_in_set ||
> -	    sb->nr_in_set <= sb->nr_this_dev ||
> -	    sb->nr_in_set > MAX_CACHES_PER_SET)
> +	if (sb->nr_in_set != 1 || sb->nr_this_dev != 0)
>   		goto err;
>   
>   	err = "Journal buckets not sequential";


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

end of thread, other threads:[~2021-11-01  5:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-01  3:07 [PATCH] bcache: make checkings for sb.nr_in_set and sb.nr_this_dev to be more precise Lin Feng
2021-11-01  5:29 ` Coly Li

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