From: Kent Overstreet Date: Thu, 16 Dec 2021 01:35:45 +0000 (-0500) Subject: bcachefs: Fix an assertion in bch2_truncate() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=51c4e406aa5706cdb224ff16eef1d560c504c3ac;p=users%2Fjedix%2Flinux-maple.git bcachefs: Fix an assertion in bch2_truncate() We recently added an assertion that when we truncate a file to 0, i_blocks should also go to 0 - but that's not necessarily true if we're doing an emergency shutdown, lots of invariants no longer hold true in that case. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 2f144fa3298de..28bbbac5cd670 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -2699,7 +2699,8 @@ int bch2_truncate(struct mnt_idmap *idmap, U64_MAX, &i_sectors_delta); i_sectors_acct(c, inode, NULL, i_sectors_delta); - BUG_ON(!inode->v.i_size && inode->v.i_blocks); + WARN_ON(!inode->v.i_size && inode->v.i_blocks && + !bch2_journal_error(&c->journal)); if (unlikely(ret)) goto err;