summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_trans_commit.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-11-08 22:00:00 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-01 11:47:37 -0500
commit9a71de675f97acafdcda7bf4ce4ba10247c1db00 (patch)
tree49037721d00519f40d01e744bcea822bb40edc31 /fs/bcachefs/btree_trans_commit.c
parent389c92b36e302d866c2850e70560667ac4a826c6 (diff)
downloadlinux-9a71de675f97acafdcda7bf4ce4ba10247c1db00.tar.gz
linux-9a71de675f97acafdcda7bf4ce4ba10247c1db00.tar.bz2
linux-9a71de675f97acafdcda7bf4ce4ba10247c1db00.zip
bcachefs: BTREE_INSERT_JOURNAL_REPLAY now "don't init trans->journal_res"
This slightly changes how trans->journal_res works, in preparation for changing the btree write buffer flush path to use it. Now, BTREE_INSERT_JOURNAL_REPLAY means "don't take a journal reservation; trans->journal_res.seq already refers to the journal sequence number to pin". Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_trans_commit.c')
-rw-r--r--fs/bcachefs/btree_trans_commit.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_trans_commit.c b/fs/bcachefs/btree_trans_commit.c
index 4d0f388f2be1..6c5510c4a2c4 100644
--- a/fs/bcachefs/btree_trans_commit.c
+++ b/fs/bcachefs/btree_trans_commit.c
@@ -676,8 +676,6 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
if (unlikely(trans->journal_transaction_names))
journal_transaction_name(trans);
- } else {
- trans->journal_res.seq = c->journal.replay_journal_seq;
}
/*
@@ -896,7 +894,8 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, unsigned flags
* Drop journal reservation after dropping write locks, since dropping
* the journal reservation may kick off a journal write:
*/
- bch2_journal_res_put(&c->journal, &trans->journal_res);
+ if (likely(!(flags & BTREE_INSERT_JOURNAL_REPLAY)))
+ bch2_journal_res_put(&c->journal, &trans->journal_res);
return ret;
}
@@ -1139,7 +1138,8 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
}
retry:
bch2_trans_verify_not_in_restart(trans);
- memset(&trans->journal_res, 0, sizeof(trans->journal_res));
+ if (likely(!(flags & BTREE_INSERT_JOURNAL_REPLAY)))
+ memset(&trans->journal_res, 0, sizeof(trans->journal_res));
ret = do_bch2_trans_commit(trans, flags, &i, _RET_IP_);
@@ -1164,5 +1164,16 @@ err:
if (ret)
goto out;
+ /*
+ * We might have done another transaction commit in the error path -
+ * i.e. btree write buffer flush - which will have made use of
+ * trans->journal_res, but with BTREE_INSERT_JOURNAL_REPLAY that is how
+ * the journal sequence number to pin is passed in - so we must restart:
+ */
+ if (flags & BTREE_INSERT_JOURNAL_REPLAY) {
+ ret = -BCH_ERR_transaction_restart_nested;
+ goto out;
+ }
+
goto retry;
}