diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-12 00:31:50 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-01 19:47:37 +0300 |
commit | cb52d23e77a6e5e9588962ba7e283b0d0d2c1976 (patch) | |
tree | 0ef5cb88faca56b5856ca8d76fe6ae615726038f /fs/bcachefs/btree_trans_commit.c | |
parent | 5927310dcfc9360ca7f8366b468ad52681bf5a27 (diff) | |
download | linux-cb52d23e77a6e5e9588962ba7e283b0d0d2c1976.tar.xz |
bcachefs: Rename BTREE_INSERT flags
BTREE_INSERT flags are actually transaction commit flags - rename them
for clarity.
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.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/fs/bcachefs/btree_trans_commit.c b/fs/bcachefs/btree_trans_commit.c index 117ce5352242..4bdb847dd688 100644 --- a/fs/bcachefs/btree_trans_commit.c +++ b/fs/bcachefs/btree_trans_commit.c @@ -408,7 +408,7 @@ static int btree_key_can_insert_cached(struct btree_trans *trans, unsigned flags if (!test_bit(BKEY_CACHED_DIRTY, &ck->flags) && bch2_btree_key_cache_must_wait(c) && - !(flags & BTREE_INSERT_JOURNAL_RECLAIM)) + !(flags & BCH_TRANS_COMMIT_journal_reclaim)) return -BCH_ERR_btree_insert_need_journal_reclaim; /* @@ -667,7 +667,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, * Don't get journal reservation until after we know insert will * succeed: */ - if (likely(!(flags & BTREE_INSERT_JOURNAL_REPLAY))) { + if (likely(!(flags & BCH_TRANS_COMMIT_no_journal_res))) { ret = bch2_trans_journal_res_get(trans, (flags & BCH_WATERMARK_MASK)| JOURNAL_RES_GET_NONBLOCK); @@ -684,7 +684,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, */ if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG) && - !(flags & BTREE_INSERT_JOURNAL_REPLAY)) { + !(flags & BCH_TRANS_COMMIT_no_journal_res)) { if (bch2_journal_seq_verify) trans_for_each_update(trans, i) i->k->k.version.lo = trans->journal_res.seq; @@ -698,7 +698,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, return -BCH_ERR_btree_insert_need_mark_replicas; if (trans->nr_wb_updates) { - EBUG_ON(flags & BTREE_INSERT_JOURNAL_REPLAY); + EBUG_ON(flags & BCH_TRANS_COMMIT_no_journal_res); ret = bch2_btree_insert_keys_write_buffer(trans); if (ret) @@ -735,7 +735,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, trans->journal_res.u64s -= trans->extra_journal_entries.nr; } - if (likely(!(flags & BTREE_INSERT_JOURNAL_REPLAY))) { + if (likely(!(flags & BCH_TRANS_COMMIT_no_journal_res))) { struct journal *j = &c->journal; struct jset_entry *entry; @@ -889,7 +889,7 @@ 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: */ - if (likely(!(flags & BTREE_INSERT_JOURNAL_REPLAY))) + if (likely(!(flags & BCH_TRANS_COMMIT_no_journal_res))) bch2_journal_res_put(&c->journal, &trans->journal_res); return ret; @@ -927,7 +927,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags, * XXX: this should probably be a separate BTREE_INSERT_NONBLOCK * flag */ - if ((flags & BTREE_INSERT_JOURNAL_RECLAIM) && + if ((flags & BCH_TRANS_COMMIT_journal_reclaim) && (flags & BCH_WATERMARK_MASK) != BCH_WATERMARK_reclaim) { ret = -BCH_ERR_journal_reclaim_would_deadlock; break; @@ -962,7 +962,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags, if (wb->state.nr > wb->size * 3 / 4) { bch2_trans_begin(trans); ret = __bch2_btree_write_buffer_flush(trans, - flags|BTREE_INSERT_NOCHECK_RW, true); + flags|BCH_TRANS_COMMIT_no_check_rw, true); if (!ret) { trace_and_count(c, trans_restart_write_buffer_flush, trans, _THIS_IP_); ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_write_buffer_flush); @@ -982,7 +982,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags, BUG_ON(bch2_err_matches(ret, BCH_ERR_transaction_restart) != !!trans->restarted); bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOSPC) && - (flags & BTREE_INSERT_NOFAIL), c, + (flags & BCH_TRANS_COMMIT_no_enospc), c, "%s: incorrectly got %s\n", __func__, bch2_err_str(ret)); return ret; @@ -994,7 +994,7 @@ bch2_trans_commit_get_rw_cold(struct btree_trans *trans, unsigned flags) struct bch_fs *c = trans->c; int ret; - if (likely(!(flags & BTREE_INSERT_LAZY_RW)) || + if (likely(!(flags & BCH_TRANS_COMMIT_lazy_rw)) || test_bit(BCH_FS_STARTED, &c->flags)) return -BCH_ERR_erofs_trans_commit; @@ -1047,7 +1047,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags) struct printbuf buf = PRINTBUF; enum bkey_invalid_flags invalid_flags = 0; - if (!(flags & BTREE_INSERT_JOURNAL_REPLAY)) + if (!(flags & BCH_TRANS_COMMIT_no_journal_res)) invalid_flags |= BKEY_INVALID_WRITE|BKEY_INVALID_COMMIT; if (unlikely(bch2_bkey_invalid(c, bkey_i_to_s_c(i->k), @@ -1065,7 +1065,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags) goto out_reset; } - if (!(flags & BTREE_INSERT_NOCHECK_RW) && + if (!(flags & BCH_TRANS_COMMIT_no_check_rw) && unlikely(!bch2_write_ref_tryget(c, BCH_WRITE_REF_trans))) { ret = bch2_trans_commit_get_rw_cold(trans, flags); if (ret) @@ -1078,7 +1078,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags) bch2_trans_unlock(trans); ret = __bch2_btree_write_buffer_flush(trans, - flags|BTREE_INSERT_NOCHECK_RW, true); + flags|BCH_TRANS_COMMIT_no_check_rw, true); if (!ret) { trace_and_count(c, trans_restart_write_buffer_flush, trans, _THIS_IP_); ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_write_buffer_flush); @@ -1122,14 +1122,14 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags) if (trans->extra_journal_res) { ret = bch2_disk_reservation_add(c, trans->disk_res, trans->extra_journal_res, - (flags & BTREE_INSERT_NOFAIL) + (flags & BCH_TRANS_COMMIT_no_enospc) ? BCH_DISK_RESERVATION_NOFAIL : 0); if (ret) goto err; } retry: bch2_trans_verify_not_in_restart(trans); - if (likely(!(flags & BTREE_INSERT_JOURNAL_REPLAY))) + if (likely(!(flags & BCH_TRANS_COMMIT_no_journal_res))) memset(&trans->journal_res, 0, sizeof(trans->journal_res)); ret = do_bch2_trans_commit(trans, flags, &i, _RET_IP_); @@ -1142,7 +1142,7 @@ retry: trace_and_count(c, transaction_commit, trans, _RET_IP_); out: - if (likely(!(flags & BTREE_INSERT_NOCHECK_RW))) + if (likely(!(flags & BCH_TRANS_COMMIT_no_check_rw))) bch2_write_ref_put(c, BCH_WRITE_REF_trans); out_reset: if (!ret) @@ -1158,10 +1158,11 @@ err: /* * 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: + * trans->journal_res, but with BCH_TRANS_COMMIT_no_journal_res that is + * how the journal sequence number to pin is passed in - so we must + * restart: */ - if (flags & BTREE_INSERT_JOURNAL_REPLAY) { + if (flags & BCH_TRANS_COMMIT_no_journal_res) { ret = -BCH_ERR_transaction_restart_nested; goto out; } |