diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-08-12 19:45:01 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:38 +0300 |
commit | c497df8b85a7be22373d3d2e57e067285ebcd731 (patch) | |
tree | e2714b1c634e65af4fae611f1ef3f74966e46f9d /fs/bcachefs | |
parent | 45b033fa1afd35a8eab0af003ffac9413548f476 (diff) | |
download | linux-c497df8b85a7be22373d3d2e57e067285ebcd731.tar.xz |
bcachefs: Increment restart count in bch2_trans_begin()
Instead of counting transaction restarts, count when the transaction is
restarted: if bch2_trans_begin() was called when the transaction wasn't
restarted we need to ensure restart_count is still incremented.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 1 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.h | 1 | ||||
-rw-r--r-- | fs/bcachefs/fsck.c | 10 |
3 files changed, 5 insertions, 7 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index ff0834049d94..08f39687e964 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -3229,6 +3229,7 @@ u32 bch2_trans_begin(struct btree_trans *trans) bch2_trans_reset_updates(trans); + trans->restart_count++; trans->mem_top = 0; if (trans->fs_usage_deltas) { diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index aa4d2a5df34e..c0b3c9d06505 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -218,7 +218,6 @@ static inline int btree_trans_restart_nounlock(struct btree_trans *trans, int er BUG_ON(!bch2_err_matches(err, BCH_ERR_transaction_restart)); trans->restarted = err; - trans->restart_count++; return -err; } diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index c93e177a314f..ef2e32864580 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -1149,13 +1149,11 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w) } } fsck_err: - if (ret) { + if (ret) bch_err(c, "error from check_i_sectors(): %s", bch2_err_str(ret)); - return ret; - } - if (trans_was_restarted(trans, restart_count)) - return -BCH_ERR_transaction_restart_nested; - return 0; + if (!ret && trans_was_restarted(trans, restart_count)) + ret = -BCH_ERR_transaction_restart_nested; + return ret; } static int check_extent(struct btree_trans *trans, struct btree_iter *iter, |