From ff929515cc52ed693ff2116be3af9f32122e9b54 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 28 Oct 2019 19:33:59 -0400 Subject: [PATCH] bcachefs: Trust btree alloc info at runtime This lets us avoid a cache miss in the write path. Signed-off-by: Kent Overstreet Signed-off-by: Kent Overstreet --- fs/bcachefs/bcachefs.h | 1 + fs/bcachefs/buckets.c | 2 +- fs/bcachefs/recovery.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 093dc906353d5..f8a040115fd1c 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -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, }; diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index 34d3b117085ba..0c2ca7601fdea 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -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 diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 23f3ed54faddd..2c441a2780446 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -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) { -- 2.30.2