Skip to content

Commit e660d7c

Browse files
author
Kent Overstreet
committed
bcachefs: Kill ERO for i_blocks check in truncate
Replace with logging the error in the superblock. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 3a72e36 commit e660d7c

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

fs/bcachefs/fs-io.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,22 @@ int bchfs_truncate(struct mnt_idmap *idmap,
517517
goto err;
518518
}
519519

520-
bch2_fs_inconsistent_on(!inode->v.i_size && inode->v.i_blocks &&
521-
!bch2_journal_error(&c->journal), c,
522-
"inode %lu truncated to 0 but i_blocks %llu (ondisk %lli)",
523-
inode->v.i_ino, (u64) inode->v.i_blocks,
524-
inode->ei_inode.bi_sectors);
520+
if (unlikely(!inode->v.i_size && inode->v.i_blocks &&
521+
!bch2_journal_error(&c->journal))) {
522+
struct printbuf buf = PRINTBUF;
523+
bch2_log_msg_start(c, &buf);
524+
prt_printf(&buf,
525+
"inode %lu truncated to 0 but i_blocks %llu (ondisk %lli)",
526+
inode->v.i_ino, (u64) inode->v.i_blocks,
527+
inode->ei_inode.bi_sectors);
528+
529+
bool repeat = false, print = false, suppress = false;
530+
bch2_count_fsck_err(c, vfs_inode_i_blocks_not_zero_at_truncate, buf.buf,
531+
&repeat, &print, &suppress);
532+
if (print)
533+
bch2_print_str(c, buf.buf);
534+
printbuf_exit(&buf);
535+
}
525536

526537
ret = bch2_setattr_nonsize(idmap, inode, iattr);
527538
err:

fs/bcachefs/sb-errors_format.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ enum bch_fsck_flags {
238238
x(inode_journal_seq_in_future, 299, FSCK_AUTOFIX) \
239239
x(inode_i_sectors_underflow, 312, FSCK_AUTOFIX) \
240240
x(vfs_inode_i_blocks_underflow, 311, FSCK_AUTOFIX) \
241+
x(vfs_inode_i_blocks_not_zero_at_truncate, 313, FSCK_AUTOFIX) \
241242
x(deleted_inode_but_clean, 211, FSCK_AUTOFIX) \
242243
x(deleted_inode_missing, 212, FSCK_AUTOFIX) \
243244
x(deleted_inode_is_dir, 213, FSCK_AUTOFIX) \
@@ -321,7 +322,7 @@ enum bch_fsck_flags {
321322
x(dirent_stray_data_after_cf_name, 305, 0) \
322323
x(rebalance_work_incorrectly_set, 309, FSCK_AUTOFIX) \
323324
x(rebalance_work_incorrectly_unset, 310, FSCK_AUTOFIX) \
324-
x(MAX, 313, 0)
325+
x(MAX, 314, 0)
325326

326327
enum bch_sb_error_id {
327328
#define x(t, n, ...) BCH_FSCK_ERR_##t = n,

0 commit comments

Comments
 (0)