diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-12-03 02:30:06 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:08:49 +0300 |
commit | 7bfbbd88024d70947761e482c856522b43a98d87 (patch) | |
tree | cd413be10726fad4e9018d9ea37de171fe7653aa | |
parent | b206df6e15ca85d0bb777a5548834c8685e99bc8 (diff) | |
download | linux-7bfbbd88024d70947761e482c856522b43a98d87.tar.xz |
bcachefs: Fix spurious alloc errors on forced shutdown
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/btree_update_interior.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index ac91006f3c69..aed54d5b5251 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -544,6 +544,17 @@ static void btree_update_nodes_written(struct btree_update *as) unsigned i; int ret; + /* + * If we're already in an error state, it might be because a btree node + * was never written, and we might be trying to free that same btree + * node here, but it won't have been marked as allocated and we'll see + * spurious disk usage inconsistencies in the transactional part below + * if we don't skip it: + */ + ret = bch2_journal_error(&c->journal); + if (ret) + goto err; + BUG_ON(!journal_pin_active(&as->journal)); /* @@ -569,8 +580,10 @@ static void btree_update_nodes_written(struct btree_update *as) BTREE_INSERT_JOURNAL_RESERVED, btree_update_nodes_written_trans(&trans, as)); bch2_trans_exit(&trans); - BUG_ON(ret && !bch2_journal_error(&c->journal)); + bch2_fs_fatal_err_on(ret && !bch2_journal_error(&c->journal), c, + "error %i in btree_update_nodes_written()", ret); +err: if (b) { /* * @b is the node we did the final insert into: |