diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-17 10:51:58 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:09:50 +0200 |
commit | 5f5c74661713327309f124e247de61db6729bc3d (patch) | |
tree | d610d3875696b9303795a9a6e76abf7c84135599 /fs/bcachefs/recovery.c | |
parent | bcachefs: Kill trans->flags (diff) | |
download | linux-5f5c74661713327309f124e247de61db6729bc3d.tar.xz linux-5f5c74661713327309f124e247de61db6729bc3d.zip |
bcachefs: Start copygc when first going read-write
In the distant past, it wasn't possible to start copygc until after
journal replay had finished. Now, the btree iterator code overlays keys
from the journal, so there's no reason not to start it earlier - and it
solves a rare deadlock.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/recovery.c')
-rw-r--r-- | fs/bcachefs/recovery.c | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 80736be21b9f..ebdf9f754e08 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -1267,6 +1267,20 @@ use_clean: goto err; bch_verbose(c, "done checking need_discard and freespace btrees"); + if (c->sb.version < bcachefs_metadata_version_snapshot_2) { + err = "error creating root snapshot node"; + ret = bch2_fs_initialize_subvolumes(c); + if (ret) + goto err; + } + + bch_verbose(c, "reading snapshots table"); + err = "error reading snapshots table"; + ret = bch2_fs_snapshots_start(c); + if (ret) + goto err; + bch_verbose(c, "reading snapshots done"); + set_bit(BCH_FS_MAY_GO_RW, &c->flags); bch_info(c, "starting journal replay, %zu keys", c->journal_keys.nr); @@ -1293,7 +1307,6 @@ use_clean: bch_verbose(c, "done checking alloc to lru refs"); set_bit(BCH_FS_CHECK_ALLOC_TO_LRU_REFS_DONE, &c->flags); } else { - set_bit(BCH_FS_MAY_GO_RW, &c->flags); set_bit(BCH_FS_INITIAL_GC_DONE, &c->flags); set_bit(BCH_FS_CHECK_LRUS_DONE, &c->flags); set_bit(BCH_FS_CHECK_ALLOC_TO_LRU_REFS_DONE, &c->flags); @@ -1302,6 +1315,22 @@ use_clean: if (c->opts.norecovery) goto out; + if (c->sb.version < bcachefs_metadata_version_snapshot_2) { + err = "error creating root snapshot node"; + ret = bch2_fs_initialize_subvolumes(c); + if (ret) + goto err; + } + + bch_verbose(c, "reading snapshots table"); + err = "error reading snapshots table"; + ret = bch2_fs_snapshots_start(c); + if (ret) + goto err; + bch_verbose(c, "reading snapshots done"); + + set_bit(BCH_FS_MAY_GO_RW, &c->flags); + bch_verbose(c, "starting journal replay, %zu keys", c->journal_keys.nr); err = "journal replay failed"; ret = bch2_journal_replay(c, last_seq, blacklist_seq - 1); @@ -1317,22 +1346,6 @@ use_clean: goto err; if (c->sb.version < bcachefs_metadata_version_snapshot_2) { - bch2_fs_lazy_rw(c); - - err = "error creating root snapshot node"; - ret = bch2_fs_initialize_subvolumes(c); - if (ret) - goto err; - } - - bch_verbose(c, "reading snapshots table"); - err = "error reading snapshots table"; - ret = bch2_fs_snapshots_start(c); - if (ret) - goto err; - bch_verbose(c, "reading snapshots done"); - - if (c->sb.version < bcachefs_metadata_version_snapshot_2) { /* set bi_subvol on root inode */ err = "error upgrade root inode for subvolumes"; ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_LAZY_RW, |