> 2023年5月17日 11:51,Lin Feng <linf@xxxxxxxxxx> 写道: > > In fact due to this check in cache_alloc: > free = roundup_pow_of_two(ca->sb.nbuckets) >> 10; This was introduced from commit 78365411b344d (“bcache: Rework allocator reserves”). - free = roundup_pow_of_two(ca->sb.nbuckets) >> 9; - free = max_t(size_t, free, (prio_buckets(ca) + 8) * 2); + free = roundup_pow_of_two(ca->sb.nbuckets) >> 10; > if (!free) { > ret = -EPERM; > err = "ca->sb.nbuckets is too small"; > goto err_free; > } > we can only create bcache device with nbuckets greater than 512, > so this patch is to make the codes logic consistent. > > Signed-off-by: Lin Feng <linf@xxxxxxxxxx> > --- > drivers/md/bcache/super.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c > index 7e9d19fd21dd..681a7ea442b9 100644 > --- a/drivers/md/bcache/super.c > +++ b/drivers/md/bcache/super.c > @@ -110,7 +110,7 @@ static const char *read_super_common(struct cache_sb *sb, struct block_device * > goto err; > > err = "Not enough buckets"; > - if (sb->nbuckets < 1 << 7) > + if (sb->nbuckets <= 1 << 9) if (roundup_pow_of_two(ca->sb.nbuckets) < 1<< 10) Might be more clear? > goto err; > > err = "Bad block size (not power of 2)"; In bcache-tools the minimum nbuckets is (1<<7) too. It is fine to modify it to 1<<10, I will modify bcache-tools too. Nice catch, thanks! Coly