bcachefs: Kill ERO in __bch2_i_sectors_acct()
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 1 May 2025 03:18:49 +0000 (23:18 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 1 May 2025 10:19:58 +0000 (06:19 -0400)
We won't be root causing this in the immediate future, and it's fairly
innocuous - so just log it in the superblock.

https://github.com/koverstreet/bcachefs/issues/869

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-io.c
fs/bcachefs/sb-errors_format.h

index 65c2c33d253dff8e2db8e8b9e05d6df39e450cd0..28619b6bd327038517318041a323e50f83eb1437 100644 (file)
@@ -144,10 +144,25 @@ int __must_check bch2_write_inode_size(struct bch_fs *c,
 void __bch2_i_sectors_acct(struct bch_fs *c, struct bch_inode_info *inode,
                           struct quota_res *quota_res, s64 sectors)
 {
-       bch2_fs_inconsistent_on((s64) inode->v.i_blocks + sectors < 0, c,
-                               "inode %lu i_blocks underflow: %llu + %lli < 0 (ondisk %lli)",
-                               inode->v.i_ino, (u64) inode->v.i_blocks, sectors,
-                               inode->ei_inode.bi_sectors);
+       if (unlikely((s64) inode->v.i_blocks + sectors < 0)) {
+               struct printbuf buf = PRINTBUF;
+               bch2_log_msg_start(c, &buf);
+               prt_printf(&buf, "inode %lu i_blocks underflow: %llu + %lli < 0 (ondisk %lli)",
+                          inode->v.i_ino, (u64) inode->v.i_blocks, sectors,
+                          inode->ei_inode.bi_sectors);
+
+               bool repeat = false, print = false, suppress = false;
+               bch2_count_fsck_err(c, vfs_inode_i_blocks_underflow, buf.buf, &repeat, &print, &suppress);
+               if (print)
+                       bch2_print_str(c, buf.buf);
+               printbuf_exit(&buf);
+
+               if (sectors < 0)
+                       sectors = -inode->v.i_blocks;
+               else
+                       sectors = 0;
+       }
+
        inode->v.i_blocks += sectors;
 
 #ifdef CONFIG_BCACHEFS_QUOTA
index a4ad5924107b2374ec74ced382337adf409101cb..582e77cbaf8fc394ddf658e15e4821aa16a76032 100644 (file)
@@ -236,6 +236,7 @@ enum bch_fsck_flags {
        x(inode_has_child_snapshots_wrong,                      287,    0)              \
        x(inode_unreachable,                                    210,    FSCK_AUTOFIX)   \
        x(inode_journal_seq_in_future,                          299,    FSCK_AUTOFIX)   \
+       x(vfs_inode_i_blocks_underflow,                         311,    FSCK_AUTOFIX)   \
        x(deleted_inode_but_clean,                              211,    FSCK_AUTOFIX)   \
        x(deleted_inode_missing,                                212,    FSCK_AUTOFIX)   \
        x(deleted_inode_is_dir,                                 213,    FSCK_AUTOFIX)   \
@@ -317,7 +318,9 @@ enum bch_fsck_flags {
        x(directory_size_mismatch,                              303,    FSCK_AUTOFIX)   \
        x(dirent_cf_name_too_big,                               304,    0)              \
        x(dirent_stray_data_after_cf_name,                      305,    0)              \
-       x(MAX,                                                  308,    0)
+       x(rebalance_work_incorrectly_set,                       309,    FSCK_AUTOFIX)   \
+       x(rebalance_work_incorrectly_unset,                     310,    FSCK_AUTOFIX)   \
+       x(MAX,                                                  312,    0)
 
 enum bch_sb_error_id {
 #define x(t, n, ...) BCH_FSCK_ERR_##t = n,