]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Fix for btree_gc repairing interior btree ptrs
authorKent Overstreet <kent.overstreet@gmail.com>
Mon, 19 Apr 2021 21:07:20 +0000 (17:07 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:01 +0000 (17:09 -0400)
Using the normal transaction commit path to insert and journal updates
to interior nodes hadn't been done before this repair code was written,
not surprising that there was a bug.

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

index 6e26531eb67133013afdb154c858bbd1815e1294..96b53effded7b521b946731e247e00599924fbc4 100644 (file)
@@ -307,8 +307,7 @@ btree_key_can_insert_cached(struct btree_trans *trans,
 }
 
 static inline void do_btree_insert_one(struct btree_trans *trans,
-                                      struct btree_iter *iter,
-                                      struct bkey_i *insert)
+                                      struct btree_insert_entry *i)
 {
        struct bch_fs *c = trans->c;
        struct journal *j = &c->journal;
@@ -317,20 +316,22 @@ static inline void do_btree_insert_one(struct btree_trans *trans,
        EBUG_ON(trans->journal_res.ref !=
                !(trans->flags & BTREE_INSERT_JOURNAL_REPLAY));
 
-       insert->k.needs_whiteout = false;
+       i->k->k.needs_whiteout = false;
 
-       did_work = (btree_iter_type(iter) != BTREE_ITER_CACHED)
-               ? btree_insert_key_leaf(trans, iter, insert)
-               : bch2_btree_insert_key_cached(trans, iter, insert);
+       did_work = (btree_iter_type(i->iter) != BTREE_ITER_CACHED)
+               ? btree_insert_key_leaf(trans, i->iter, i->k)
+               : bch2_btree_insert_key_cached(trans, i->iter, i->k);
        if (!did_work)
                return;
 
        if (likely(!(trans->flags & BTREE_INSERT_JOURNAL_REPLAY))) {
                bch2_journal_add_keys(j, &trans->journal_res,
-                                     iter->btree_id, insert);
+                                     i->btree_id,
+                                     i->level,
+                                     i->k);
 
                bch2_journal_set_has_inode(j, &trans->journal_res,
-                                          insert->k.p.inode);
+                                          i->k->k.p.inode);
 
                if (trans->journal_seq)
                        *trans->journal_seq = trans->journal_res.seq;
@@ -468,7 +469,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
                bch2_trans_mark_gc(trans);
 
        trans_for_each_update2(trans, i)
-               do_btree_insert_one(trans, i->iter, i->k);
+               do_btree_insert_one(trans, i);
 err:
        if (marking) {
                percpu_up_read(&c->mark_lock);
index cc497125889f2cbea8f3b754d3c72fd4c1c33aeb..1d556790b38ee09d3eb2450efbc9904b9dd1dcb0 100644 (file)
@@ -241,10 +241,11 @@ static inline void bch2_journal_add_entry(struct journal *j, struct journal_res
 }
 
 static inline void bch2_journal_add_keys(struct journal *j, struct journal_res *res,
-                                       enum btree_id id, const struct bkey_i *k)
+                                       enum btree_id id, unsigned level,
+                                       const struct bkey_i *k)
 {
        bch2_journal_add_entry(j, res, BCH_JSET_ENTRY_btree_keys,
-                              id, 0, k, k->k.u64s);
+                              id, level, k, k->k.u64s);
 }
 
 static inline bool journal_entry_empty(struct jset *j)