bcache: kill macro MAX_CACHES_PER_SET
PATCH 1/1 bcache: kill macro MAX_CACHES_PER_SET
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 macro defination for MAX_CACHES_PER_SET as 8 is misleading now.
In fact it should be redefined to 1 and valid number fo sb.nr_in_set should be 1 and sb.nr_this_dev should always be 0.
But jset's disk layout replies on MAX_CACHES_PER_SET(8), so replace it with a hardcoded number 8.
--- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/super.c | 4 +--- include/uapi/linux/bcache.h | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-)
drivers/md/bcache/bcache.h +1 -1
@@ -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 */
drivers/md/bcache/super.c +1 -3
@@ -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" ;
include/uapi/linux/bcache.h +2 -2
@@ -155,7 +155,6 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)#define SB_LABEL_SIZE 32#define SB_JOURNAL_BUCKETS 256U/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */ -#define MAX_CACHES_PER_SET 8#define BDEV_DATA_START_DEFAULT 16/* sectors */
@@ -356,7 +355,8 @@ struct jset {__u16 btree_level;__u16 pad[3 ]; -__u64 prio_bucket[MAX_CACHES_PER_SET ]; +/* only a single cache is available */ +__u64 prio_bucket[8 ];union {struct bkey start[0 ];
Signature · 1 line
2.31.1
Quoted 37 lines · Lin Feng
Commit
697e23495c94f0380c1ed8b11f830b92b64c99ea
("bcache: explicitly makecache_setonly have single cache") explicitly makes acache_setonly have single cache and based on the fact that historily only one cache is ever used in the cache set, so macro defination forMAX_CACHES_PER_SETas 8 is misleading now.In fact it should be redefined to 1 and valid number fo sb.nr_in_set should be 1 and sb.nr_this_dev should always be 0.
But jset's disk layout replies on
MAX_CACHES_PER_SET(8), so replace it with a hardcoded number 8.Signed-off-by Lin Feng <[email protected]>--- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/super.c | 4 +--- include/uapi/linux/bcache.h | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-)drivers/md/bcache/bcache.h +1
-1@@ -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 */ drivers/md/bcache/super.c +0
-0
drivers/md/bcache/super.c static const char *read_super_common(struct cache_sb *sb, struct block_device * · line 146
Quoted 10 lines
drivers/md/bcache/super.c +1
-3@@ -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" ;
Hi Feng,
The above changes are fine to me. But let's keep the below part as what it is at this moment.
Thanks.
Coly Li
Quoted 22 lines
include/uapi/linux/bcache.h +2
-2@@ -155,7 +155,6 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)#define SB_LABEL_SIZE 32#define SB_JOURNAL_BUCKETS 256U/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */ -#define MAX_CACHES_PER_SET 8#define BDEV_DATA_START_DEFAULT 16/* sectors */ @@ -356,7 +355,8 @@ struct jset {__u16 btree_level;__u16 pad[3 ]; -__u64 prio_bucket[MAX_CACHES_PER_SET ]; +/* only a single cache is available */ +__u64 prio_bucket[8 ];union {struct bkey start[0 ];
Hi Coly,
OK, I will send another patch but keep MAX_CACHES_PER_SET, thanks :)
linfeng
Quoted 80 lines · Coly Li
Quoted 37 lines · Lin Feng
Commit
697e23495c94f0380c1ed8b11f830b92b64c99ea
("bcache: explicitly makecache_setonly have single cache") explicitly makes acache_setonly have single cache and based on the fact that historily only one cache is ever used in the cache set, so macro defination forMAX_CACHES_PER_SETas 8 is misleading now.In fact it should be redefined to 1 and valid number fo sb.nr_in_set should be 1 and sb.nr_this_dev should always be 0.
But jset's disk layout replies on
MAX_CACHES_PER_SET(8), so replace it with a hardcoded number 8.Signed-off-by Lin Feng <[email protected]>--- drivers/md/bcache/bcache.h | 2 +- drivers/md/bcache/super.c | 4 +--- include/uapi/linux/bcache.h | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-)drivers/md/bcache/bcache.h +1
-1@@ -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 */ drivers/md/bcache/super.c +0
-0drivers/md/bcache/super.c static const char *read_super_common(struct cache_sb *sb, struct block_device * · line 146
Quoted 10 lines
drivers/md/bcache/super.c +1
-3@@ -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" ;Hi Feng,
The above changes are fine to me. But let's keep the below part as what it is at this moment.
Thanks.
Coly Li
Quoted 22 lines
include/uapi/linux/bcache.h +2
-2@@ -155,7 +155,6 @@ static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)#define SB_LABEL_SIZE 32#define SB_JOURNAL_BUCKETS 256U/* SB_JOURNAL_BUCKETS must be divisible by BITS_PER_LONG */ -#define MAX_CACHES_PER_SET 8#define BDEV_DATA_START_DEFAULT 16/* sectors */ @@ -356,7 +355,8 @@ struct jset {__u16 btree_level;__u16 pad[3 ]; -__u64 prio_bucket[MAX_CACHES_PER_SET ]; +/* only a single cache is available */ +__u64 prio_bucket[8 ];union {struct bkey start[0 ];