bcachefs: Fix check_inode_update_hardlinks()
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 30 Sep 2021 15:09:26 +0000 (11:09 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:13 +0000 (17:09 -0400)
We were incorrectly using bch2_inode_write(), which gets the snapshot ID
from the iterator, with a BTREE_ITER_ALL_SNAPSHOTS iterator -
fortunately caught by an assertion in the update path.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/fsck.c

index 16a1eae9b374b953ddb9f7078214745325fc6ddb..3622fb4d18e22df3290622d2ba82bfa977abcbd4 100644 (file)
@@ -2094,11 +2094,7 @@ static int check_nlinks_update_hardlinks(struct bch_fs *c,
                                bch2_inode_nlink_get(&u), link->count)) {
                        bch2_inode_nlink_set(&u, link->count);
 
-                       ret = __bch2_trans_do(&trans, NULL, NULL,
-                                             BTREE_INSERT_NOFAIL|
-                                             BTREE_INSERT_LAZY_RW,
-                                             bch2_btree_iter_traverse(&iter) ?:
-                                       bch2_inode_write(&trans, &iter, &u));
+                       ret = write_inode(&trans, &u, k.k->p.snapshot);
                        if (ret)
                                bch_err(c, "error in fsck: error %i updating inode", ret);
                }