summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-10-29 02:33:59 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:30 +0300
commitff929515cc52ed693ff2116be3af9f32122e9b54 (patch)
tree275f7c6ab71076f6e6c40048d545b11a36df4e47 /fs
parentc4e065c23c4ad464be2fb1c4dfa70090cc3d0c66 (diff)
downloadlinux-ff929515cc52ed693ff2116be3af9f32122e9b54.tar.xz
bcachefs: Trust btree alloc info at runtime
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/bcachefs.h1
-rw-r--r--fs/bcachefs/buckets.c2
-rw-r--r--fs/bcachefs/recovery.c2
3 files changed, 4 insertions, 1 deletions
diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h
index 093dc906353d..f8a040115fd1 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 34d3b117085b..0c2ca7601fde 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 23f3ed54fadd..2c441a278044 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) {