diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/bcache/bcache.h | 3 | ||||
-rw-r--r-- | drivers/md/bcache/super.c | 6 | ||||
-rw-r--r-- | drivers/md/bcache/sysfs.c | 6 |
3 files changed, 15 insertions, 0 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index 83f60cde9693..e67523dd5073 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h @@ -212,6 +212,9 @@ #include "stats_types.h" #include "super_types.h" +/* 256k, in sectors */ +#define BTREE_NODE_SIZE_MAX 512 + struct btree; struct cache; diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index a7dd332b17d8..7f25591f7897 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -261,6 +261,12 @@ const char *validate_super(struct bcache_superblock *disk_sb, if (!CACHE_BTREE_NODE_SIZE(sb)) return "Btree node size not set"; + if (!is_power_of_2(CACHE_BTREE_NODE_SIZE(sb))) + return "Btree node size not a power of two"; + + if (CACHE_BTREE_NODE_SIZE(sb) > BTREE_NODE_SIZE_MAX) + return "Btree node size too large"; + if (sb->u64s < bch_journal_buckets_offset(sb)) return "Invalid superblock: member info area missing"; diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 4268c679b96e..91540fd0de8f 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -77,6 +77,8 @@ read_attribute(bucket_size); read_attribute(bucket_size_bytes); read_attribute(block_size); read_attribute(block_size_bytes); +read_attribute(btree_node_size); +read_attribute(btree_node_size_bytes); read_attribute(first_bucket); read_attribute(nbuckets); read_attribute(tree_depth); @@ -603,6 +605,8 @@ SHOW(bch_cache_set) sysfs_hprint(block_size, block_bytes(c)); sysfs_print(block_size_bytes, block_bytes(c)); + sysfs_hprint(btree_node_size, CACHE_BTREE_NODE_SIZE(&c->sb) << 9); + sysfs_print(btree_node_size_bytes, CACHE_BTREE_NODE_SIZE(&c->sb) << 9); sysfs_hprint(btree_cache_size, bch_cache_size(c)); sysfs_print(btree_cache_max_chain, bch_cache_max_chain(c)); @@ -994,6 +998,8 @@ static struct attribute *bch_cache_set_files[] = { &sysfs_block_size, &sysfs_block_size_bytes, + &sysfs_btree_node_size, + &sysfs_btree_node_size_bytes, &sysfs_tree_depth, &sysfs_root_usage_percent, &sysfs_btree_cache_size, |