bcachefs: minor fsck fix
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 31 Mar 2019 23:23:34 +0000 (19:23 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:19 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fsck.c

index 661131d5a114fc22f2e07b0400b29798f3b19893..9db01437315b7f32a1d0b0753b4062d4b2c0d7b8 100644 (file)
@@ -1240,12 +1240,10 @@ static int check_inode(struct btree_trans *trans,
                        return ret;
        }
 
-       if (u.bi_flags & BCH_INODE_UNLINKED) {
-               fsck_err_on(c->sb.clean, c,
-                           "filesystem marked clean, "
-                           "but inode %llu unlinked",
-                           u.bi_inum);
-
+       if (u.bi_flags & BCH_INODE_UNLINKED &&
+           (!c->sb.clean ||
+            fsck_err(c, "filesystem marked clean, but inode %llu unlinked",
+                     u.bi_inum))) {
                bch_verbose(c, "deleting inode %llu", u.bi_inum);
 
                ret = bch2_inode_rm(c, u.bi_inum);
@@ -1255,12 +1253,10 @@ static int check_inode(struct btree_trans *trans,
                return ret;
        }
 
-       if (u.bi_flags & BCH_INODE_I_SIZE_DIRTY) {
-               fsck_err_on(c->sb.clean, c,
-                           "filesystem marked clean, "
-                           "but inode %llu has i_size dirty",
-                           u.bi_inum);
-
+       if (u.bi_flags & BCH_INODE_I_SIZE_DIRTY &&
+           (!c->sb.clean ||
+            fsck_err(c, "filesystem marked clean, but inode %llu has i_size dirty",
+                     u.bi_inum))) {
                bch_verbose(c, "truncating inode %llu", u.bi_inum);
 
                /*
@@ -1285,14 +1281,12 @@ static int check_inode(struct btree_trans *trans,
                do_update = true;
        }
 
-       if (u.bi_flags & BCH_INODE_I_SECTORS_DIRTY) {
+       if (u.bi_flags & BCH_INODE_I_SECTORS_DIRTY &&
+           (!c->sb.clean ||
+            fsck_err(c, "filesystem marked clean, but inode %llu has i_sectors dirty",
+                     u.bi_inum))) {
                s64 sectors;
 
-               fsck_err_on(c->sb.clean, c,
-                           "filesystem marked clean, "
-                           "but inode %llu has i_sectors dirty",
-                           u.bi_inum);
-
                bch_verbose(c, "recounting sectors for inode %llu",
                            u.bi_inum);