diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-04-01 08:29:59 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:30 +0300 |
commit | 822835ffeae411bbc8af104da9331fdf63a7bc12 (patch) | |
tree | 57d2b7fd487fc05d58464ea179d435ff4d149bc9 /fs/bcachefs/recovery.c | |
parent | 8058ea64c31c8700eaab48c38a143d1c3817f1de (diff) | |
download | linux-822835ffeae411bbc8af104da9331fdf63a7bc12.tar.xz |
bcachefs: Fold bucket_state in to BCH_DATA_TYPES()
Previously, we were missing accounting for buckets in need_gc_gens and
need_discard states. This matters because buckets in those states need
other btree operations done before they can be used, so they can't be
conuted when checking current number of free buckets against the
allocation watermark.
Also, we weren't directly counting free buckets at all. Now, data type 0
== BCH_DATA_free, and free buckets are counted; this means we can get
rid of the separate (poorly defined) count of unavailable buckets.
This is a new on disk format version, with upgrade and fsck required for
the accounting changes.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/recovery.c')
-rw-r--r-- | fs/bcachefs/recovery.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 1fe3e81eaa3d..fd0c2a203619 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -713,7 +713,6 @@ static int journal_replay_entry_early(struct bch_fs *c, unsigned i, nr_types = jset_entry_dev_usage_nr_types(u); ca->usage_base->buckets_ec = le64_to_cpu(u->buckets_ec); - ca->usage_base->buckets_unavailable = le64_to_cpu(u->buckets_unavailable); for (i = 0; i < min_t(unsigned, nr_types, BCH_DATA_NR); i++) { ca->usage_base->d[i].buckets = le64_to_cpu(u->d[i].buckets); @@ -1080,18 +1079,11 @@ int bch2_fs_recovery(struct bch_fs *c) } if (!c->opts.nochanges) { - if (c->sb.version < bcachefs_metadata_version_inode_backpointers) { - bch_info(c, "version prior to inode backpointers, upgrade and fsck required"); + if (c->sb.version < bcachefs_metadata_version_new_data_types) { + bch_info(c, "version prior to new_data_types, upgrade and fsck required"); c->opts.version_upgrade = true; c->opts.fsck = true; c->opts.fix_errors = FSCK_OPT_YES; - } else if (c->sb.version < bcachefs_metadata_version_subvol_dirent) { - bch_info(c, "filesystem version is prior to subvol_dirent - upgrading"); - c->opts.version_upgrade = true; - c->opts.fsck = true; - } else if (c->sb.version < bcachefs_metadata_version_alloc_v4) { - bch_info(c, "filesystem version is prior to alloc_v4 - upgrading"); - c->opts.version_upgrade = true; } } @@ -1436,6 +1428,9 @@ int bch2_fs_initialize(struct bch_fs *c) for (i = 0; i < BTREE_ID_NR; i++) bch2_btree_root_alloc(c, i); + for_each_online_member(ca, c, i) + bch2_dev_usage_init(ca); + err = "unable to allocate journal buckets"; for_each_online_member(ca, c, i) { ret = bch2_dev_journal_alloc(ca); |