summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-12-15 20:35:45 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2021-12-25 17:37:12 -0500
commitd45807a9cf5bcf9b5ee47212039207e91d981253 (patch)
treecbf980884b1fd2f826c334091882bc666c60bab0
parent5fe678dcfff1dd6879c8cdf6d9ca874280913b89 (diff)
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 <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/fs-io.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index 4ad843fa7e95..9cdd03f3eeb0 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -2705,7 +2705,8 @@ int bch2_truncate(struct user_namespace *mnt_userns,
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;