diff options
| author | Greg Kroah-Hartman <[email protected]> | 2025-05-13 06:19:37 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <[email protected]> | 2025-05-13 06:19:37 +0000 |
| commit | 991919e969043a4422dfebbcadf600a5d28b94e4 (patch) | |
| tree | 4776f9f162c665a9735198fafc466d3e49a14253 /fs/bcachefs/io_write.c | |
| parent | comedi: drivers: adl_pci9118.c: Edit file so that checkpatch.pl has 0 typo er... (diff) | |
| parent | Linux 6.15-rc6 (diff) | |
| download | kernel-991919e969043a4422dfebbcadf600a5d28b94e4.tar.gz kernel-991919e969043a4422dfebbcadf600a5d28b94e4.zip | |
Merge 6.15-rc6 into char-misc-next
We need the iio/hyperv fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'fs/bcachefs/io_write.c')
| -rw-r--r-- | fs/bcachefs/io_write.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/bcachefs/io_write.c b/fs/bcachefs/io_write.c index a418fa62f09d..c1237da079ed 100644 --- a/fs/bcachefs/io_write.c +++ b/fs/bcachefs/io_write.c @@ -255,6 +255,27 @@ static inline int bch2_extent_update_i_size_sectors(struct btree_trans *trans, } if (i_sectors_delta) { + s64 bi_sectors = le64_to_cpu(inode->v.bi_sectors); + if (unlikely(bi_sectors + i_sectors_delta < 0)) { + struct bch_fs *c = trans->c; + struct printbuf buf = PRINTBUF; + bch2_log_msg_start(c, &buf); + prt_printf(&buf, "inode %llu i_sectors underflow: %lli + %lli < 0", + extent_iter->pos.inode, bi_sectors, i_sectors_delta); + + bool repeat = false, print = false, suppress = false; + bch2_count_fsck_err(c, inode_i_sectors_underflow, buf.buf, + &repeat, &print, &suppress); + if (print) + bch2_print_str(c, buf.buf); + printbuf_exit(&buf); + + if (i_sectors_delta < 0) + i_sectors_delta = -bi_sectors; + else + i_sectors_delta = 0; + } + le64_add_cpu(&inode->v.bi_sectors, i_sectors_delta); inode_update_flags = 0; } |
