bcachefs: Trust btree alloc info at runtime
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 28 Oct 2019 23:33:59 +0000 (19:33 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:30 +0000 (17:08 -0400)
This lets us avoid a cache miss in the write path.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs.h
fs/bcachefs/buckets.c
fs/bcachefs/recovery.c

index 093dc906353d58e29389345c3747bf17a724b04e..f8a040115fd1cbc9301d52372957b4aa046a8b85 100644 (file)
@@ -499,6 +499,7 @@ enum {
        /* misc: */
        BCH_FS_BDEV_MOUNTED,
        BCH_FS_FIXED_GENS,
+       BCH_FS_ALLOC_WRITTEN,
        BCH_FS_REBUILD_REPLICAS,
        BCH_FS_HOLD_BTREE_WRITES,
 };
index 34d3b117085ba3a83e26a94c007d119711b2e433..0c2ca7601fdea08df826c01c48bc8dc907094ad0 100644 (file)
@@ -1456,7 +1456,7 @@ static int bch2_trans_mark_pointer(struct btree_trans *trans,
        if (ret < 0)
                return ret;
 
-       if (!ret) {
+       if (!ret && unlikely(!test_bit(BCH_FS_ALLOC_WRITTEN, &c->flags))) {
                /*
                 * During journal replay, and if gc repairs alloc info at
                 * runtime, the alloc info in the btree might not be up to date
index 23f3ed54faddd4c9d04ec828771680ed486c1ded..2c441a278044656188c3ef519c5cddcf6b0788e9 100644 (file)
@@ -864,6 +864,8 @@ int bch2_fs_recovery(struct bch_fs *c)
                        goto err;
                }
                bch_verbose(c, "alloc write done");
+
+               set_bit(BCH_FS_ALLOC_WRITTEN, &c->flags);
        }
 
        if (!c->sb.clean) {