bcachefs: Fix an assertion in bch2_truncate()
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 16 Dec 2021 01:35:45 +0000 (20:35 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:18 +0000 (17:09 -0400)
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 <kent.overstreet@gmail.com>
fs/bcachefs/fs-io.c

index 2f144fa3298dee58ec511232d7cb8693dbbb9b46..28bbbac5cd6706f61c005cce17d1312b2558db88 100644 (file)
@@ -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;