Skip to content

Commit 05450c4

Browse files
author
Kent Overstreet
committed
bcachefs: Kill ERO in __bch2_i_sectors_acct()
We won't be root causing this in the immediate future, and it's fairly innocuous - so just log it in the superblock. koverstreet/bcachefs#869 Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 5e63d57 commit 05450c4

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

fs/bcachefs/fs-io.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,25 @@ int __must_check bch2_write_inode_size(struct bch_fs *c,
144144
void __bch2_i_sectors_acct(struct bch_fs *c, struct bch_inode_info *inode,
145145
struct quota_res *quota_res, s64 sectors)
146146
{
147-
bch2_fs_inconsistent_on((s64) inode->v.i_blocks + sectors < 0, c,
148-
"inode %lu i_blocks underflow: %llu + %lli < 0 (ondisk %lli)",
149-
inode->v.i_ino, (u64) inode->v.i_blocks, sectors,
150-
inode->ei_inode.bi_sectors);
147+
if (unlikely((s64) inode->v.i_blocks + sectors < 0)) {
148+
struct printbuf buf = PRINTBUF;
149+
bch2_log_msg_start(c, &buf);
150+
prt_printf(&buf, "inode %lu i_blocks underflow: %llu + %lli < 0 (ondisk %lli)",
151+
inode->v.i_ino, (u64) inode->v.i_blocks, sectors,
152+
inode->ei_inode.bi_sectors);
153+
154+
bool repeat = false, print = false, suppress = false;
155+
bch2_count_fsck_err(c, vfs_inode_i_blocks_underflow, buf.buf, &repeat, &print, &suppress);
156+
if (print)
157+
bch2_print_str(c, buf.buf);
158+
printbuf_exit(&buf);
159+
160+
if (sectors < 0)
161+
sectors = -inode->v.i_blocks;
162+
else
163+
sectors = 0;
164+
}
165+
151166
inode->v.i_blocks += sectors;
152167

153168
#ifdef CONFIG_BCACHEFS_QUOTA

fs/bcachefs/sb-errors_format.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ enum bch_fsck_flags {
236236
x(inode_has_child_snapshots_wrong, 287, 0) \
237237
x(inode_unreachable, 210, FSCK_AUTOFIX) \
238238
x(inode_journal_seq_in_future, 299, FSCK_AUTOFIX) \
239+
x(vfs_inode_i_blocks_underflow, 311, FSCK_AUTOFIX) \
239240
x(deleted_inode_but_clean, 211, FSCK_AUTOFIX) \
240241
x(deleted_inode_missing, 212, FSCK_AUTOFIX) \
241242
x(deleted_inode_is_dir, 213, FSCK_AUTOFIX) \
@@ -317,7 +318,9 @@ enum bch_fsck_flags {
317318
x(directory_size_mismatch, 303, FSCK_AUTOFIX) \
318319
x(dirent_cf_name_too_big, 304, 0) \
319320
x(dirent_stray_data_after_cf_name, 305, 0) \
320-
x(MAX, 308, 0)
321+
x(rebalance_work_incorrectly_set, 309, FSCK_AUTOFIX) \
322+
x(rebalance_work_incorrectly_unset, 310, FSCK_AUTOFIX) \
323+
x(MAX, 312, 0)
321324

322325
enum bch_sb_error_id {
323326
#define x(t, n, ...) BCH_FSCK_ERR_##t = n,

0 commit comments

Comments
 (0)