diff options
author | 2021-12-14 14:24:41 -0500 | |
---|---|---|
committer | 2023-10-22 17:09:19 -0400 | |
commit | 8244f3209b5b49a6bde9921d7825af9f57161b23 (patch) | |
tree | 344a619bee4976ff0983bf0bb6bba7b81e532a71 /fs/bcachefs/super-io.c | |
parent | bcachefs: Fix debugfs -bfloat-failed (diff) | |
download | linux-8244f3209b5b49a6bde9921d7825af9f57161b23.tar.gz linux-8244f3209b5b49a6bde9921d7825af9f57161b23.tar.bz2 linux-8244f3209b5b49a6bde9921d7825af9f57161b23.zip |
bcachefs: Option improvements
This adds flags for options that must be a power of two (block size and
btree node size), and options that are stored in the superblock as a
power of two (encoded extent max).
Also: options are now stored in memory in the same units they're
displayed in (bytes): we now convert when getting and setting from the
superblock.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/super-io.c')
-rw-r--r-- | fs/bcachefs/super-io.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index 170f7d46fa34..c831d32c26fe 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -267,8 +267,7 @@ const char *bch2_sb_validate(struct bch_sb_handle *disk_sb) block_size = le16_to_cpu(sb->block_size); - if (!is_power_of_2(block_size) || - block_size > PAGE_SECTORS) + if (block_size > PAGE_SECTORS) return "Bad block size"; if (bch2_is_zero(sb->user_uuid.b, sizeof(sb->user_uuid))) @@ -310,9 +309,6 @@ const char *bch2_sb_validate(struct bch_sb_handle *disk_sb) if (!BCH_SB_BTREE_NODE_SIZE(sb)) return "Btree node size not set"; - if (!is_power_of_2(BCH_SB_BTREE_NODE_SIZE(sb))) - return "Btree node size not a power of two"; - if (BCH_SB_GC_RESERVE(sb) < 5) return "gc reserve percentage too small"; @@ -627,8 +623,12 @@ got_super: err = "Superblock block size smaller than device block size"; ret = -EINVAL; if (le16_to_cpu(sb->sb->block_size) << 9 < - bdev_logical_block_size(sb->bdev)) - goto err; + bdev_logical_block_size(sb->bdev)) { + pr_err("error reading superblock: Superblock block size (%u) smaller than device block size (%u)", + le16_to_cpu(sb->sb->block_size) << 9, + bdev_logical_block_size(sb->bdev)); + goto err_no_print; + } ret = 0; sb->have_layout = true; @@ -636,8 +636,9 @@ out: pr_verbose_init(*opts, "ret %i", ret); return ret; err: - bch2_free_super(sb); pr_err("error reading superblock: %s", err); +err_no_print: + bch2_free_super(sb); goto out; } |