Commit 30ca6ece authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Kill trans->flags

Recursive transaction commits are occasionally necessary - in
particular, for the upcoming btree write buffer's flush path.

This avoids bugs due to trans->flags being accidentally mutated
mid-commit, which can cause c->writes refcount leaks.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 60b55388
...@@ -769,6 +769,7 @@ int bch2_btree_key_cache_flush(struct btree_trans *trans, ...@@ -769,6 +769,7 @@ int bch2_btree_key_cache_flush(struct btree_trans *trans,
} }
bool bch2_btree_insert_key_cached(struct btree_trans *trans, bool bch2_btree_insert_key_cached(struct btree_trans *trans,
unsigned flags,
struct btree_path *path, struct btree_path *path,
struct bkey_i *insert) struct bkey_i *insert)
{ {
...@@ -778,7 +779,7 @@ bool bch2_btree_insert_key_cached(struct btree_trans *trans, ...@@ -778,7 +779,7 @@ bool bch2_btree_insert_key_cached(struct btree_trans *trans,
BUG_ON(insert->u64s > ck->u64s); BUG_ON(insert->u64s > ck->u64s);
if (likely(!(trans->flags & BTREE_INSERT_JOURNAL_REPLAY))) { if (likely(!(flags & BTREE_INSERT_JOURNAL_REPLAY))) {
int difference; int difference;
BUG_ON(jset_u64s(insert->u64s) > trans->journal_preres.u64s); BUG_ON(jset_u64s(insert->u64s) > trans->journal_preres.u64s);
......
...@@ -29,7 +29,7 @@ bch2_btree_key_cache_find(struct bch_fs *, enum btree_id, struct bpos); ...@@ -29,7 +29,7 @@ bch2_btree_key_cache_find(struct bch_fs *, enum btree_id, struct bpos);
int bch2_btree_path_traverse_cached(struct btree_trans *, struct btree_path *, int bch2_btree_path_traverse_cached(struct btree_trans *, struct btree_path *,
unsigned); unsigned);
bool bch2_btree_insert_key_cached(struct btree_trans *, bool bch2_btree_insert_key_cached(struct btree_trans *, unsigned,
struct btree_path *, struct bkey_i *); struct btree_path *, struct bkey_i *);
int bch2_btree_key_cache_flush(struct btree_trans *, int bch2_btree_key_cache_flush(struct btree_trans *,
enum btree_id, struct bpos); enum btree_id, struct bpos);
......
...@@ -458,7 +458,6 @@ struct btree_trans { ...@@ -458,7 +458,6 @@ struct btree_trans {
struct journal_preres journal_preres; struct journal_preres journal_preres;
u64 *journal_seq; u64 *journal_seq;
struct disk_reservation *disk_res; struct disk_reservation *disk_res;
unsigned flags;
unsigned journal_u64s; unsigned journal_u64s;
unsigned journal_preres_u64s; unsigned journal_preres_u64s;
struct replicas_delta_list *fs_usage_deltas; struct replicas_delta_list *fs_usage_deltas;
......
...@@ -80,7 +80,7 @@ int __must_check bch2_trans_update(struct btree_trans *, struct btree_iter *, ...@@ -80,7 +80,7 @@ int __must_check bch2_trans_update(struct btree_trans *, struct btree_iter *,
void bch2_trans_commit_hook(struct btree_trans *, void bch2_trans_commit_hook(struct btree_trans *,
struct btree_trans_commit_hook *); struct btree_trans_commit_hook *);
int __bch2_trans_commit(struct btree_trans *); int __bch2_trans_commit(struct btree_trans *, unsigned);
int bch2_trans_log_msg(struct btree_trans *, const char *, ...); int bch2_trans_log_msg(struct btree_trans *, const char *, ...);
int bch2_fs_log_msg(struct bch_fs *, const char *, ...); int bch2_fs_log_msg(struct bch_fs *, const char *, ...);
...@@ -101,9 +101,8 @@ static inline int bch2_trans_commit(struct btree_trans *trans, ...@@ -101,9 +101,8 @@ static inline int bch2_trans_commit(struct btree_trans *trans,
{ {
trans->disk_res = disk_res; trans->disk_res = disk_res;
trans->journal_seq = journal_seq; trans->journal_seq = journal_seq;
trans->flags = flags;
return __bch2_trans_commit(trans); return __bch2_trans_commit(trans, flags);
} }
#define commit_do(_trans, _disk_res, _journal_seq, _flags, _do) \ #define commit_do(_trans, _disk_res, _journal_seq, _flags, _do) \
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment