summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/recovery.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-03-16 21:22:47 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-03-17 21:17:38 -0400
commita58603684195ea892da5612580762fd3151b2a7b (patch)
treec716679279dfab8d1f758e542da8e86c0d5aef96 /fs/bcachefs/recovery.c
parentf3589bfa7ee4aff118908e910d05ba96b1858633 (diff)
downloadlinux-a58603684195ea892da5612580762fd3151b2a7b.tar.gz
linux-a58603684195ea892da5612580762fd3151b2a7b.tar.bz2
linux-a58603684195ea892da5612580762fd3151b2a7b.zip
bcachefs: Don't corrupt journal keys gap buffer when dropping alloc info
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/recovery.c')
-rw-r--r--fs/bcachefs/recovery.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index 2af219aedfdb..03f9d6afe467 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -90,10 +90,12 @@ static void do_reconstruct_alloc(struct bch_fs *c)
struct journal_keys *keys = &c->journal_keys;
size_t src, dst;
+ move_gap(keys, keys->nr);
+
for (src = 0, dst = 0; src < keys->nr; src++)
if (!btree_id_is_alloc(keys->data[src].btree_id))
keys->data[dst++] = keys->data[src];
- keys->nr = dst;
+ keys->nr = keys->gap = dst;
}
/*
@@ -203,6 +205,8 @@ static int bch2_journal_replay(struct bch_fs *c)
BUG_ON(!atomic_read(&keys->ref));
+ move_gap(keys, keys->nr);
+
/*
* First, attempt to replay keys in sorted order. This is more
* efficient - better locality of btree access - but some might fail if