]> git.dujemihanovic.xyz Git - linux.git/commitdiff
bcachefs: Fix reattach_inode()
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 28 Sep 2024 06:44:12 +0000 (02:44 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 5 Oct 2024 00:25:31 +0000 (20:25 -0400)
Ensure a copy of the lost+found inode exists in the snapshot that we're
reattaching, so that we don't trigger warnings in
lookup_inode_for_snapshot() later.

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

index 351de61c7ed120cdd76bf29a2b9e6d027061a606..881ad5b9447fd88d85c83363877ca65b38f21e10 100644 (file)
@@ -354,13 +354,12 @@ static int reattach_inode(struct btree_trans *trans,
        if (ret)
                return ret;
 
-       if (S_ISDIR(inode->bi_mode)) {
-               lostfound.bi_nlink++;
+       lostfound.bi_nlink += S_ISDIR(inode->bi_mode);
 
-               ret = __bch2_fsck_write_inode(trans, &lostfound, U32_MAX);
-               if (ret)
-                       return ret;
-       }
+       /* ensure lost+found inode is also present in inode snapshot */
+       ret = __bch2_fsck_write_inode(trans, &lostfound, inode_snapshot);
+       if (ret)
+               return ret;
 
        dir_hash = bch2_hash_info_init(c, &lostfound);