mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
set btree_node_size for the cache_sb based on bucket_size
Change-Id: I98dab6e9a221cd8781095039d653ace84ffae806 Signed-off-by: Jacob Malevich <jam@daterainc.com>
This commit is contained in:
parent
e8c1cee578
commit
ee44c4f509
28
bcache.c
28
bcache.c
@ -530,12 +530,34 @@ int dev_open(const char *dev, bool wipe_bcache)
|
||||
return fd;
|
||||
}
|
||||
|
||||
static unsigned min_bucket_size(int num_bucket_sizes, unsigned *bucket_sizes)
|
||||
{
|
||||
int i;
|
||||
unsigned min = bucket_sizes[0];
|
||||
|
||||
for (i = 0; i < num_bucket_sizes; i++)
|
||||
min = bucket_sizes[i] < min ? bucket_sizes[i] : min;
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
static unsigned node_size(unsigned bucket_size) {
|
||||
|
||||
if (bucket_size <= 256)
|
||||
return bucket_size;
|
||||
else if (bucket_size <= 512)
|
||||
return bucket_size / 2;
|
||||
else
|
||||
return bucket_size / 4;
|
||||
}
|
||||
|
||||
void write_cache_sbs(int *fds, struct cache_sb *sb,
|
||||
unsigned block_size, unsigned *bucket_sizes,
|
||||
int num_bucket_sizes)
|
||||
{
|
||||
char uuid_str[40], set_uuid_str[40];
|
||||
size_t i;
|
||||
unsigned min_size = min_bucket_size(num_bucket_sizes, bucket_sizes);
|
||||
|
||||
sb->offset = SB_SECTOR;
|
||||
sb->version = BCACHE_SB_VERSION_CDEV_V3;
|
||||
@ -552,11 +574,13 @@ void write_cache_sbs(int *fds, struct cache_sb *sb,
|
||||
for (i = 0; i < sb->nr_in_set; i++) {
|
||||
struct cache_member *m = sb->members + i;
|
||||
|
||||
sb->uuid = m->uuid;
|
||||
if(num_bucket_sizes <= 1)
|
||||
if (num_bucket_sizes <= 1)
|
||||
sb->bucket_size = bucket_sizes[0];
|
||||
else
|
||||
sb->bucket_size = bucket_sizes[i];
|
||||
SET_CACHE_BTREE_NODE_SIZE(sb, node_size(min_size));
|
||||
|
||||
sb->uuid = m->uuid;
|
||||
sb->nbuckets = getblocks(fds[i]) / sb->bucket_size;
|
||||
sb->nr_this_dev = i;
|
||||
sb->first_bucket = (23 / sb->bucket_size) + 1;
|
||||
|
Loading…
Reference in New Issue
Block a user