Commit cb52d23e authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Rename BTREE_INSERT flags

BTREE_INSERT flags are actually transaction commit flags - rename them
for clarity.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 5927310d
...@@ -561,8 +561,8 @@ int bch2_bucket_gens_init(struct bch_fs *c) ...@@ -561,8 +561,8 @@ int bch2_bucket_gens_init(struct bch_fs *c)
if (have_bucket_gens_key && bkey_cmp(iter.pos, pos)) { if (have_bucket_gens_key && bkey_cmp(iter.pos, pos)) {
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW, BCH_TRANS_COMMIT_lazy_rw,
bch2_btree_insert_trans(trans, BTREE_ID_bucket_gens, &g.k_i, 0)); bch2_btree_insert_trans(trans, BTREE_ID_bucket_gens, &g.k_i, 0));
if (ret) if (ret)
break; break;
...@@ -581,8 +581,8 @@ int bch2_bucket_gens_init(struct bch_fs *c) ...@@ -581,8 +581,8 @@ int bch2_bucket_gens_init(struct bch_fs *c)
if (have_bucket_gens_key && !ret) if (have_bucket_gens_key && !ret)
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW, BCH_TRANS_COMMIT_lazy_rw,
bch2_btree_insert_trans(trans, BTREE_ID_bucket_gens, &g.k_i, 0)); bch2_btree_insert_trans(trans, BTREE_ID_bucket_gens, &g.k_i, 0));
bch2_trans_put(trans); bch2_trans_put(trans);
...@@ -1267,7 +1267,7 @@ static noinline_for_stack int bch2_check_discard_freespace_key(struct btree_tran ...@@ -1267,7 +1267,7 @@ static noinline_for_stack int bch2_check_discard_freespace_key(struct btree_tran
ret = bch2_btree_delete_extent_at(trans, iter, ret = bch2_btree_delete_extent_at(trans, iter,
iter->btree_id == BTREE_ID_freespace ? 1 : 0, 0) ?: iter->btree_id == BTREE_ID_freespace ? 1 : 0, 0) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL|BTREE_INSERT_LAZY_RW); BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw);
goto out; goto out;
} }
...@@ -1404,8 +1404,8 @@ int bch2_check_alloc_info(struct bch_fs *c) ...@@ -1404,8 +1404,8 @@ int bch2_check_alloc_info(struct bch_fs *c)
} }
ret = bch2_trans_commit(trans, NULL, NULL, ret = bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW); BCH_TRANS_COMMIT_lazy_rw);
if (ret) if (ret)
goto bkey_err; goto bkey_err;
...@@ -1463,7 +1463,7 @@ int bch2_check_alloc_info(struct bch_fs *c) ...@@ -1463,7 +1463,7 @@ int bch2_check_alloc_info(struct bch_fs *c)
ret = for_each_btree_key_commit(trans, iter, ret = for_each_btree_key_commit(trans, iter,
BTREE_ID_bucket_gens, POS_MIN, BTREE_ID_bucket_gens, POS_MIN,
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_NOFAIL|BTREE_INSERT_LAZY_RW, NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw,
bch2_check_bucket_gens_key(trans, &iter, k)); bch2_check_bucket_gens_key(trans, &iter, k));
err: err:
bch2_trans_put(trans); bch2_trans_put(trans);
...@@ -1556,7 +1556,7 @@ int bch2_check_alloc_to_lru_refs(struct bch_fs *c) ...@@ -1556,7 +1556,7 @@ int bch2_check_alloc_to_lru_refs(struct bch_fs *c)
ret = bch2_trans_run(c, ret = bch2_trans_run(c,
for_each_btree_key_commit(trans, iter, BTREE_ID_alloc, for_each_btree_key_commit(trans, iter, BTREE_ID_alloc,
POS_MIN, BTREE_ITER_PREFETCH, k, POS_MIN, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_NOFAIL|BTREE_INSERT_LAZY_RW, NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw,
bch2_check_alloc_to_lru_ref(trans, &iter))); bch2_check_alloc_to_lru_ref(trans, &iter)));
if (ret) if (ret)
bch_err_fn(c, ret); bch_err_fn(c, ret);
...@@ -1665,7 +1665,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans, ...@@ -1665,7 +1665,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
ret = bch2_trans_update(trans, &iter, &a->k_i, 0) ?: ret = bch2_trans_update(trans, &iter, &a->k_i, 0) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BCH_WATERMARK_btree| BCH_WATERMARK_btree|
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
if (ret) if (ret)
goto out; goto out;
...@@ -1770,7 +1770,7 @@ static int invalidate_one_bucket(struct btree_trans *trans, ...@@ -1770,7 +1770,7 @@ static int invalidate_one_bucket(struct btree_trans *trans,
BTREE_TRIGGER_BUCKET_INVALIDATE) ?: BTREE_TRIGGER_BUCKET_INVALIDATE) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BCH_WATERMARK_btree| BCH_WATERMARK_btree|
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
if (ret) if (ret)
goto out; goto out;
...@@ -1894,8 +1894,8 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca, ...@@ -1894,8 +1894,8 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca,
ret = bch2_bucket_do_index(trans, k, a, true) ?: ret = bch2_bucket_do_index(trans, k, a, true) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_LAZY_RW| BCH_TRANS_COMMIT_lazy_rw|
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
if (ret) if (ret)
goto bkey_err; goto bkey_err;
...@@ -1915,8 +1915,8 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca, ...@@ -1915,8 +1915,8 @@ int bch2_dev_freespace_init(struct bch_fs *c, struct bch_dev *ca,
ret = bch2_btree_insert_trans(trans, BTREE_ID_freespace, freespace, 0) ?: ret = bch2_btree_insert_trans(trans, BTREE_ID_freespace, freespace, 0) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_LAZY_RW| BCH_TRANS_COMMIT_lazy_rw|
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
if (ret) if (ret)
goto bkey_err; goto bkey_err;
......
...@@ -382,7 +382,7 @@ int bch2_check_btree_backpointers(struct bch_fs *c) ...@@ -382,7 +382,7 @@ int bch2_check_btree_backpointers(struct bch_fs *c)
ret = bch2_trans_run(c, ret = bch2_trans_run(c,
for_each_btree_key_commit(trans, iter, for_each_btree_key_commit(trans, iter,
BTREE_ID_backpointers, POS_MIN, 0, k, BTREE_ID_backpointers, POS_MIN, 0, k,
NULL, NULL, BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
bch2_check_btree_backpointer(trans, &iter, k))); bch2_check_btree_backpointer(trans, &iter, k)));
if (ret) if (ret)
bch_err_fn(c, ret); bch_err_fn(c, ret);
...@@ -629,8 +629,8 @@ static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans, ...@@ -629,8 +629,8 @@ static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans,
do { do {
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_LAZY_RW| BCH_TRANS_COMMIT_lazy_rw|
BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_no_enospc,
check_extent_to_backpointers(trans, &iter, check_extent_to_backpointers(trans, &iter,
bucket_start, bucket_end, bucket_start, bucket_end,
&last_flushed)); &last_flushed));
...@@ -644,8 +644,8 @@ static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans, ...@@ -644,8 +644,8 @@ static int bch2_check_extents_to_backpointers_pass(struct btree_trans *trans,
break; break;
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_LAZY_RW| BCH_TRANS_COMMIT_lazy_rw|
BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_no_enospc,
check_btree_root_to_backpointers(trans, btree_id, check_btree_root_to_backpointers(trans, btree_id,
bucket_start, bucket_end, bucket_start, bucket_end,
&last_flushed)); &last_flushed));
...@@ -807,7 +807,7 @@ static int bch2_check_backpointers_to_extents_pass(struct btree_trans *trans, ...@@ -807,7 +807,7 @@ static int bch2_check_backpointers_to_extents_pass(struct btree_trans *trans,
return for_each_btree_key_commit(trans, iter, BTREE_ID_backpointers, return for_each_btree_key_commit(trans, iter, BTREE_ID_backpointers,
POS_MIN, BTREE_ITER_PREFETCH, k, POS_MIN, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
check_one_backpointer(trans, start, end, check_one_backpointer(trans, start, end,
bkey_s_c_to_backpointer(k), bkey_s_c_to_backpointer(k),
&last_flushed_pos)); &last_flushed_pos));
......
...@@ -1499,7 +1499,7 @@ static int bch2_gc_alloc_done(struct bch_fs *c, bool metadata_only) ...@@ -1499,7 +1499,7 @@ static int bch2_gc_alloc_done(struct bch_fs *c, bool metadata_only)
ret = for_each_btree_key_commit(trans, iter, BTREE_ID_alloc, ret = for_each_btree_key_commit(trans, iter, BTREE_ID_alloc,
POS(ca->dev_idx, ca->mi.first_bucket), POS(ca->dev_idx, ca->mi.first_bucket),
BTREE_ITER_SLOTS|BTREE_ITER_PREFETCH, k, BTREE_ITER_SLOTS|BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_LAZY_RW, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw,
bch2_alloc_write_key(trans, &iter, k, metadata_only)); bch2_alloc_write_key(trans, &iter, k, metadata_only));
if (ret < 0) { if (ret < 0) {
...@@ -1657,7 +1657,7 @@ static int bch2_gc_reflink_done(struct bch_fs *c, bool metadata_only) ...@@ -1657,7 +1657,7 @@ static int bch2_gc_reflink_done(struct bch_fs *c, bool metadata_only)
ret = for_each_btree_key_commit(trans, iter, ret = for_each_btree_key_commit(trans, iter,
BTREE_ID_reflink, POS_MIN, BTREE_ID_reflink, POS_MIN,
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_gc_write_reflink_key(trans, &iter, k, &idx)); bch2_gc_write_reflink_key(trans, &iter, k, &idx));
c->reflink_gc_nr = 0; c->reflink_gc_nr = 0;
...@@ -1781,7 +1781,7 @@ static int bch2_gc_stripes_done(struct bch_fs *c, bool metadata_only) ...@@ -1781,7 +1781,7 @@ static int bch2_gc_stripes_done(struct bch_fs *c, bool metadata_only)
ret = for_each_btree_key_commit(trans, iter, ret = for_each_btree_key_commit(trans, iter,
BTREE_ID_stripes, POS_MIN, BTREE_ID_stripes, POS_MIN,
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_gc_write_stripes_key(trans, &iter, k)); bch2_gc_write_stripes_key(trans, &iter, k));
bch2_trans_put(trans); bch2_trans_put(trans);
...@@ -2017,7 +2017,7 @@ int bch2_gc_gens(struct bch_fs *c) ...@@ -2017,7 +2017,7 @@ int bch2_gc_gens(struct bch_fs *c)
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS,
k, k,
NULL, NULL, NULL, NULL,
BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_no_enospc,
gc_btree_gens_key(trans, &iter, k)); gc_btree_gens_key(trans, &iter, k));
if (ret && !bch2_err_matches(ret, EROFS)) if (ret && !bch2_err_matches(ret, EROFS))
bch_err_fn(c, ret); bch_err_fn(c, ret);
...@@ -2030,7 +2030,7 @@ int bch2_gc_gens(struct bch_fs *c) ...@@ -2030,7 +2030,7 @@ int bch2_gc_gens(struct bch_fs *c)
BTREE_ITER_PREFETCH, BTREE_ITER_PREFETCH,
k, k,
NULL, NULL, NULL, NULL,
BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_no_enospc,
bch2_alloc_write_oldest_gen(trans, &iter, k)); bch2_alloc_write_oldest_gen(trans, &iter, k));
if (ret && !bch2_err_matches(ret, EROFS)) if (ret && !bch2_err_matches(ret, EROFS))
bch_err_fn(c, ret); bch_err_fn(c, ret);
......
...@@ -1800,9 +1800,9 @@ static void btree_node_write_work(struct work_struct *work) ...@@ -1800,9 +1800,9 @@ static void btree_node_write_work(struct work_struct *work)
ret = bch2_trans_do(c, NULL, NULL, 0, ret = bch2_trans_do(c, NULL, NULL, 0,
bch2_btree_node_update_key_get_iter(trans, b, &wbio->key, bch2_btree_node_update_key_get_iter(trans, b, &wbio->key,
BCH_WATERMARK_reclaim| BCH_WATERMARK_reclaim|
BTREE_INSERT_JOURNAL_RECLAIM| BCH_TRANS_COMMIT_journal_reclaim|
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_NOCHECK_RW, BCH_TRANS_COMMIT_no_check_rw,
!wbio->wbio.failed.nr)); !wbio->wbio.failed.nr));
if (ret) if (ret)
goto err; goto err;
......
...@@ -656,8 +656,8 @@ static int btree_key_cache_flush_pos(struct btree_trans *trans, ...@@ -656,8 +656,8 @@ static int btree_key_cache_flush_pos(struct btree_trans *trans,
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE| BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE|
BTREE_TRIGGER_NORUN) ?: BTREE_TRIGGER_NORUN) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOCHECK_RW| BCH_TRANS_COMMIT_no_check_rw|
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
(ck->journal.seq == journal_last_seq(j) (ck->journal.seq == journal_last_seq(j)
? BCH_WATERMARK_reclaim ? BCH_WATERMARK_reclaim
: 0)| : 0)|
...@@ -734,7 +734,7 @@ int bch2_btree_key_cache_journal_flush(struct journal *j, ...@@ -734,7 +734,7 @@ int bch2_btree_key_cache_journal_flush(struct journal *j,
ret = commit_do(trans, NULL, NULL, 0, ret = commit_do(trans, NULL, NULL, 0,
btree_key_cache_flush_pos(trans, key, seq, btree_key_cache_flush_pos(trans, key, seq,
BTREE_INSERT_JOURNAL_RECLAIM, false)); BCH_TRANS_COMMIT_journal_reclaim, false));
unlock: unlock:
srcu_read_unlock(&c->btree_trans_barrier, srcu_idx); srcu_read_unlock(&c->btree_trans_barrier, srcu_idx);
......
...@@ -408,7 +408,7 @@ static int btree_key_can_insert_cached(struct btree_trans *trans, unsigned flags ...@@ -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) && if (!test_bit(BKEY_CACHED_DIRTY, &ck->flags) &&
bch2_btree_key_cache_must_wait(c) && 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; return -BCH_ERR_btree_insert_need_journal_reclaim;
/* /*
...@@ -667,7 +667,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, ...@@ -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 * Don't get journal reservation until after we know insert will
* succeed: * succeed:
*/ */
if (likely(!(flags & BTREE_INSERT_JOURNAL_REPLAY))) { if (likely(!(flags & BCH_TRANS_COMMIT_no_journal_res))) {
ret = bch2_trans_journal_res_get(trans, ret = bch2_trans_journal_res_get(trans,
(flags & BCH_WATERMARK_MASK)| (flags & BCH_WATERMARK_MASK)|
JOURNAL_RES_GET_NONBLOCK); JOURNAL_RES_GET_NONBLOCK);
...@@ -684,7 +684,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, ...@@ -684,7 +684,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
*/ */
if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG) && if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG) &&
!(flags & BTREE_INSERT_JOURNAL_REPLAY)) { !(flags & BCH_TRANS_COMMIT_no_journal_res)) {
if (bch2_journal_seq_verify) if (bch2_journal_seq_verify)
trans_for_each_update(trans, i) trans_for_each_update(trans, i)
i->k->k.version.lo = trans->journal_res.seq; i->k->k.version.lo = trans->journal_res.seq;
...@@ -698,7 +698,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, ...@@ -698,7 +698,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
return -BCH_ERR_btree_insert_need_mark_replicas; return -BCH_ERR_btree_insert_need_mark_replicas;
if (trans->nr_wb_updates) { 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); ret = bch2_btree_insert_keys_write_buffer(trans);
if (ret) if (ret)
...@@ -735,7 +735,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags, ...@@ -735,7 +735,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
trans->journal_res.u64s -= trans->extra_journal_entries.nr; 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 journal *j = &c->journal;
struct jset_entry *entry; struct jset_entry *entry;
...@@ -889,7 +889,7 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans, unsigned flags ...@@ -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 * Drop journal reservation after dropping write locks, since dropping
* the journal reservation may kick off a journal write: * 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); bch2_journal_res_put(&c->journal, &trans->journal_res);
return ret; return ret;
...@@ -927,7 +927,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags, ...@@ -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 * XXX: this should probably be a separate BTREE_INSERT_NONBLOCK
* flag * flag
*/ */
if ((flags & BTREE_INSERT_JOURNAL_RECLAIM) && if ((flags & BCH_TRANS_COMMIT_journal_reclaim) &&
(flags & BCH_WATERMARK_MASK) != BCH_WATERMARK_reclaim) { (flags & BCH_WATERMARK_MASK) != BCH_WATERMARK_reclaim) {
ret = -BCH_ERR_journal_reclaim_would_deadlock; ret = -BCH_ERR_journal_reclaim_would_deadlock;
break; break;
...@@ -962,7 +962,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags, ...@@ -962,7 +962,7 @@ int bch2_trans_commit_error(struct btree_trans *trans, unsigned flags,
if (wb->state.nr > wb->size * 3 / 4) { if (wb->state.nr > wb->size * 3 / 4) {
bch2_trans_begin(trans); bch2_trans_begin(trans);
ret = __bch2_btree_write_buffer_flush(trans, ret = __bch2_btree_write_buffer_flush(trans,
flags|BTREE_INSERT_NOCHECK_RW, true); flags|BCH_TRANS_COMMIT_no_check_rw, true);
if (!ret) { if (!ret) {
trace_and_count(c, trans_restart_write_buffer_flush, trans, _THIS_IP_); trace_and_count(c, trans_restart_write_buffer_flush, trans, _THIS_IP_);
ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_write_buffer_flush); 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, ...@@ -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); BUG_ON(bch2_err_matches(ret, BCH_ERR_transaction_restart) != !!trans->restarted);
bch2_fs_inconsistent_on(bch2_err_matches(ret, ENOSPC) && 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)); "%s: incorrectly got %s\n", __func__, bch2_err_str(ret));
return ret; return ret;
...@@ -994,7 +994,7 @@ bch2_trans_commit_get_rw_cold(struct btree_trans *trans, unsigned flags) ...@@ -994,7 +994,7 @@ bch2_trans_commit_get_rw_cold(struct btree_trans *trans, unsigned flags)
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
int ret; int ret;
if (likely(!(flags & BTREE_INSERT_LAZY_RW)) || if (likely(!(flags & BCH_TRANS_COMMIT_lazy_rw)) ||
test_bit(BCH_FS_STARTED, &c->flags)) test_bit(BCH_FS_STARTED, &c->flags))
return -BCH_ERR_erofs_trans_commit; return -BCH_ERR_erofs_trans_commit;
...@@ -1047,7 +1047,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags) ...@@ -1047,7 +1047,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
struct printbuf buf = PRINTBUF; struct printbuf buf = PRINTBUF;
enum bkey_invalid_flags invalid_flags = 0; 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; invalid_flags |= BKEY_INVALID_WRITE|BKEY_INVALID_COMMIT;
if (unlikely(bch2_bkey_invalid(c, bkey_i_to_s_c(i->k), 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) ...@@ -1065,7 +1065,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
goto out_reset; 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))) { unlikely(!bch2_write_ref_tryget(c, BCH_WRITE_REF_trans))) {
ret = bch2_trans_commit_get_rw_cold(trans, flags); ret = bch2_trans_commit_get_rw_cold(trans, flags);
if (ret) if (ret)
...@@ -1078,7 +1078,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags) ...@@ -1078,7 +1078,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
bch2_trans_unlock(trans); bch2_trans_unlock(trans);
ret = __bch2_btree_write_buffer_flush(trans, ret = __bch2_btree_write_buffer_flush(trans,
flags|BTREE_INSERT_NOCHECK_RW, true); flags|BCH_TRANS_COMMIT_no_check_rw, true);
if (!ret) { if (!ret) {
trace_and_count(c, trans_restart_write_buffer_flush, trans, _THIS_IP_); trace_and_count(c, trans_restart_write_buffer_flush, trans, _THIS_IP_);
ret = btree_trans_restart(trans, BCH_ERR_transaction_restart_write_buffer_flush); 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) ...@@ -1122,14 +1122,14 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
if (trans->extra_journal_res) { if (trans->extra_journal_res) {
ret = bch2_disk_reservation_add(c, trans->disk_res, ret = bch2_disk_reservation_add(c, trans->disk_res,
trans->extra_journal_res, trans->extra_journal_res,
(flags & BTREE_INSERT_NOFAIL) (flags & BCH_TRANS_COMMIT_no_enospc)
? BCH_DISK_RESERVATION_NOFAIL : 0); ? BCH_DISK_RESERVATION_NOFAIL : 0);
if (ret) if (ret)
goto err; goto err;
} }
retry: retry:
bch2_trans_verify_not_in_restart(trans); 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)); memset(&trans->journal_res, 0, sizeof(trans->journal_res));
ret = do_bch2_trans_commit(trans, flags, &i, _RET_IP_); ret = do_bch2_trans_commit(trans, flags, &i, _RET_IP_);
...@@ -1142,7 +1142,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags) ...@@ -1142,7 +1142,7 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
trace_and_count(c, transaction_commit, trans, _RET_IP_); trace_and_count(c, transaction_commit, trans, _RET_IP_);
out: 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); bch2_write_ref_put(c, BCH_WRITE_REF_trans);
out_reset: out_reset:
if (!ret) if (!ret)
...@@ -1158,10 +1158,11 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags) ...@@ -1158,10 +1158,11 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
/* /*
* We might have done another transaction commit in the error path - * We might have done another transaction commit in the error path -
* i.e. btree write buffer flush - which will have made use of * i.e. btree write buffer flush - which will have made use of
* trans->journal_res, but with BTREE_INSERT_JOURNAL_REPLAY that is how * trans->journal_res, but with BCH_TRANS_COMMIT_no_journal_res that is
* the journal sequence number to pin is passed in - so we must restart: * 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; ret = -BCH_ERR_transaction_restart_nested;
goto out; goto out;
} }
......
...@@ -786,7 +786,7 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id, ...@@ -786,7 +786,7 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id,
ret = bch2_trans_update(trans, &iter, &delete, update_flags) ?: ret = bch2_trans_update(trans, &iter, &delete, update_flags) ?:
bch2_trans_commit(trans, &disk_res, journal_seq, bch2_trans_commit(trans, &disk_res, journal_seq,
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
bch2_disk_reservation_put(trans->c, &disk_res); bch2_disk_reservation_put(trans->c, &disk_res);
err: err:
/* /*
...@@ -891,7 +891,7 @@ __bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt, ...@@ -891,7 +891,7 @@ __bch2_fs_log_msg(struct bch_fs *c, unsigned commit_flags, const char *fmt,
ret = __bch2_trans_log_msg(&c->journal.early_journal_entries, fmt, args); ret = __bch2_trans_log_msg(&c->journal.early_journal_entries, fmt, args);
} else { } else {
ret = bch2_trans_do(c, NULL, NULL, ret = bch2_trans_do(c, NULL, NULL,
BTREE_INSERT_LAZY_RW|commit_flags, BCH_TRANS_COMMIT_lazy_rw|commit_flags,
__bch2_trans_log_msg(&trans->extra_journal_entries, fmt, args)); __bch2_trans_log_msg(&trans->extra_journal_entries, fmt, args));
} }
......
...@@ -21,26 +21,28 @@ void bch2_btree_add_journal_pin(struct bch_fs *, struct btree *, u64); ...@@ -21,26 +21,28 @@ void bch2_btree_add_journal_pin(struct bch_fs *, struct btree *, u64);
void bch2_btree_insert_key_leaf(struct btree_trans *, struct btree_path *, void bch2_btree_insert_key_leaf(struct btree_trans *, struct btree_path *,
struct bkey_i *, u64); struct bkey_i *, u64);
enum btree_insert_flags { #define BCH_TRANS_COMMIT_FLAGS() \
x(no_enospc, "don't check for enospc") \
x(no_check_rw, "don't attempt to take a ref on c->writes") \
x(lazy_rw, "go read-write if we haven't yet - only for use in recovery") \
x(no_journal_res, "don't take a journal reservation, instead " \
"pin journal entry referred to by trans->journal_res.seq") \
x(journal_reclaim, "operation required for journal reclaim; may return error" \
"instead of deadlocking if BCH_WATERMARK_reclaim not specified")\
enum __bch_trans_commit_flags {
/* First bits for bch_watermark: */ /* First bits for bch_watermark: */
__BTREE_INSERT_NOFAIL = BCH_WATERMARK_BITS, __BCH_TRANS_COMMIT_FLAGS_START = BCH_WATERMARK_BITS,
__BTREE_INSERT_NOCHECK_RW, #define x(n, ...) __BCH_TRANS_COMMIT_##n,
__BTREE_INSERT_LAZY_RW, BCH_TRANS_COMMIT_FLAGS()
__BTREE_INSERT_JOURNAL_REPLAY, #undef x
__BTREE_INSERT_JOURNAL_RECLAIM,
}; };
/* Don't check for -ENOSPC: */ enum bch_trans_commit_flags {
#define BTREE_INSERT_NOFAIL BIT(__BTREE_INSERT_NOFAIL) #define x(n, ...) BCH_TRANS_COMMIT_##n = BIT(__BCH_TRANS_COMMIT_##n),
BCH_TRANS_COMMIT_FLAGS()
#define BTREE_INSERT_NOCHECK_RW BIT(__BTREE_INSERT_NOCHECK_RW) #undef x
#define BTREE_INSERT_LAZY_RW BIT(__BTREE_INSERT_LAZY_RW) };
/* Insert is for journal replay - don't get journal reservations: */
#define BTREE_INSERT_JOURNAL_REPLAY BIT(__BTREE_INSERT_JOURNAL_REPLAY)
/* Insert is being called from journal reclaim path: */
#define BTREE_INSERT_JOURNAL_RECLAIM BIT(__BTREE_INSERT_JOURNAL_RECLAIM)
int bch2_btree_delete_extent_at(struct btree_trans *, struct btree_iter *, int bch2_btree_delete_extent_at(struct btree_trans *, struct btree_iter *,
unsigned, unsigned); unsigned, unsigned);
......
...@@ -641,9 +641,9 @@ static void btree_update_nodes_written(struct btree_update *as) ...@@ -641,9 +641,9 @@ static void btree_update_nodes_written(struct btree_update *as)
*/ */
ret = commit_do(trans, &as->disk_res, &journal_seq, ret = commit_do(trans, &as->disk_res, &journal_seq,
BCH_WATERMARK_reclaim| BCH_WATERMARK_reclaim|
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_NOCHECK_RW| BCH_TRANS_COMMIT_no_check_rw|
BTREE_INSERT_JOURNAL_RECLAIM, BCH_TRANS_COMMIT_journal_reclaim,
btree_update_nodes_written_trans(trans, as)); btree_update_nodes_written_trans(trans, as));
bch2_trans_unlock(trans); bch2_trans_unlock(trans);
...@@ -1050,7 +1050,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path, ...@@ -1050,7 +1050,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
struct bch_fs *c = trans->c; struct bch_fs *c = trans->c;
struct btree_update *as; struct btree_update *as;
u64 start_time = local_clock(); u64 start_time = local_clock();
int disk_res_flags = (flags & BTREE_INSERT_NOFAIL) int disk_res_flags = (flags & BCH_TRANS_COMMIT_no_enospc)
? BCH_DISK_RESERVATION_NOFAIL : 0; ? BCH_DISK_RESERVATION_NOFAIL : 0;
unsigned nr_nodes[2] = { 0, 0 }; unsigned nr_nodes[2] = { 0, 0 };
unsigned update_level = level; unsigned update_level = level;
...@@ -1068,7 +1068,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path, ...@@ -1068,7 +1068,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
flags &= ~BCH_WATERMARK_MASK; flags &= ~BCH_WATERMARK_MASK;
flags |= watermark; flags |= watermark;
if (!(flags & BTREE_INSERT_JOURNAL_RECLAIM) && if (!(flags & BCH_TRANS_COMMIT_journal_reclaim) &&
watermark < c->journal.watermark) { watermark < c->journal.watermark) {
struct journal_res res = { 0 }; struct journal_res res = { 0 };
...@@ -1162,7 +1162,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path, ...@@ -1162,7 +1162,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
* flag * flag
*/ */
if (bch2_err_matches(ret, ENOSPC) && if (bch2_err_matches(ret, ENOSPC) &&
(flags & BTREE_INSERT_JOURNAL_RECLAIM) && (flags & BCH_TRANS_COMMIT_journal_reclaim) &&
watermark != BCH_WATERMARK_reclaim) { watermark != BCH_WATERMARK_reclaim) {
ret = -BCH_ERR_journal_reclaim_would_deadlock; ret = -BCH_ERR_journal_reclaim_would_deadlock;
goto err; goto err;
...@@ -1862,7 +1862,7 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans, ...@@ -1862,7 +1862,7 @@ int __bch2_foreground_maybe_merge(struct btree_trans *trans,
parent = btree_node_parent(path, b); parent = btree_node_parent(path, b);
as = bch2_btree_update_start(trans, path, level, false, as = bch2_btree_update_start(trans, path, level, false,
BTREE_INSERT_NOFAIL|flags); BCH_TRANS_COMMIT_no_enospc|flags);
ret = PTR_ERR_OR_ZERO(as); ret = PTR_ERR_OR_ZERO(as);
if (ret) if (ret)
goto err; goto err;
...@@ -1948,7 +1948,7 @@ int bch2_btree_node_rewrite(struct btree_trans *trans, ...@@ -1948,7 +1948,7 @@ int bch2_btree_node_rewrite(struct btree_trans *trans,
struct btree_update *as; struct btree_update *as;
int ret; int ret;
flags |= BTREE_INSERT_NOFAIL; flags |= BCH_TRANS_COMMIT_no_enospc;
parent = btree_node_parent(iter->path, b); parent = btree_node_parent(iter->path, b);
as = bch2_btree_update_start(trans, iter->path, b->c.level, as = bch2_btree_update_start(trans, iter->path, b->c.level,
......
...@@ -82,10 +82,10 @@ static int bch2_btree_write_buffer_flush_one(struct btree_trans *trans, ...@@ -82,10 +82,10 @@ static int bch2_btree_write_buffer_flush_one(struct btree_trans *trans,
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?: BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
commit_flags| commit_flags|
BTREE_INSERT_NOCHECK_RW| BCH_TRANS_COMMIT_no_check_rw|
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_JOURNAL_REPLAY| BCH_TRANS_COMMIT_no_journal_res|
BTREE_INSERT_JOURNAL_RECLAIM); BCH_TRANS_COMMIT_journal_reclaim);
} }
static union btree_write_buffer_state btree_write_buffer_switch(struct btree_write_buffer *wb) static union btree_write_buffer_state btree_write_buffer_switch(struct btree_write_buffer *wb)
...@@ -175,7 +175,7 @@ int __bch2_btree_write_buffer_flush(struct btree_trans *trans, unsigned commit_f ...@@ -175,7 +175,7 @@ int __bch2_btree_write_buffer_flush(struct btree_trans *trans, unsigned commit_f
* However, since we're not flushing in the order they appear in the * However, since we're not flushing in the order they appear in the
* journal we won't be able to drop our journal pin until everything is * journal we won't be able to drop our journal pin until everything is
* flushed - which means this could deadlock the journal if we weren't * flushed - which means this could deadlock the journal if we weren't
* passing BTREE_INSERT_JOURNAL_RECLAIM. This causes the update to fail * passing BCH_TRANS_COMMIT_journal_reclaim. This causes the update to fail
* if it would block taking a journal reservation. * if it would block taking a journal reservation.
* *
* If that happens, simply skip the key so we can optimistically insert * If that happens, simply skip the key so we can optimistically insert
...@@ -264,9 +264,9 @@ int __bch2_btree_write_buffer_flush(struct btree_trans *trans, unsigned commit_f ...@@ -264,9 +264,9 @@ int __bch2_btree_write_buffer_flush(struct btree_trans *trans, unsigned commit_f
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
commit_flags| commit_flags|
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_JOURNAL_REPLAY| BCH_TRANS_COMMIT_no_journal_res|
BTREE_INSERT_JOURNAL_RECLAIM, BCH_TRANS_COMMIT_journal_reclaim,
btree_write_buffered_insert(trans, i)); btree_write_buffered_insert(trans, i));
if (bch2_fs_fatal_err_on(ret, c, "%s: insert error %s", __func__, bch2_err_str(ret))) if (bch2_fs_fatal_err_on(ret, c, "%s: insert error %s", __func__, bch2_err_str(ret)))
break; break;
...@@ -296,7 +296,7 @@ static int bch2_btree_write_buffer_journal_flush(struct journal *j, ...@@ -296,7 +296,7 @@ static int bch2_btree_write_buffer_journal_flush(struct journal *j,
mutex_lock(&wb->flush_lock); mutex_lock(&wb->flush_lock);
return bch2_trans_run(c, return bch2_trans_run(c,
__bch2_btree_write_buffer_flush(trans, BTREE_INSERT_NOCHECK_RW, true)); __bch2_btree_write_buffer_flush(trans, BCH_TRANS_COMMIT_no_check_rw, true));
} }
static inline u64 btree_write_buffer_ref(int idx) static inline u64 btree_write_buffer_ref(int idx)
......
...@@ -278,8 +278,8 @@ static int __bch2_data_update_index_update(struct btree_trans *trans, ...@@ -278,8 +278,8 @@ static int __bch2_data_update_index_update(struct btree_trans *trans,
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?: BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?:
bch2_trans_commit(trans, &op->res, bch2_trans_commit(trans, &op->res,
NULL, NULL,
BTREE_INSERT_NOCHECK_RW| BCH_TRANS_COMMIT_no_check_rw|
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
m->data_opts.btree_insert_flags); m->data_opts.btree_insert_flags);
if (!ret) { if (!ret) {
bch2_btree_iter_set_pos(&iter, next_pos); bch2_btree_iter_set_pos(&iter, next_pos);
...@@ -476,7 +476,7 @@ int bch2_extent_drop_ptrs(struct btree_trans *trans, ...@@ -476,7 +476,7 @@ int bch2_extent_drop_ptrs(struct btree_trans *trans,
return bch2_trans_relock(trans) ?: return bch2_trans_relock(trans) ?:
bch2_trans_update(trans, iter, n, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?: bch2_trans_update(trans, iter, n, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?:
bch2_trans_commit(trans, NULL, NULL, BTREE_INSERT_NOFAIL); bch2_trans_commit(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc);
} }
int bch2_data_update_init(struct btree_trans *trans, int bch2_data_update_init(struct btree_trans *trans,
......
...@@ -803,7 +803,7 @@ static void ec_stripe_delete_work(struct work_struct *work) ...@@ -803,7 +803,7 @@ static void ec_stripe_delete_work(struct work_struct *work)
if (!idx) if (!idx)
break; break;
ret = commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
ec_stripe_delete(trans, idx)); ec_stripe_delete(trans, idx));
if (ret) { if (ret) {
bch_err_fn(c, ret); bch_err_fn(c, ret);
...@@ -983,8 +983,8 @@ static int ec_stripe_update_bucket(struct btree_trans *trans, struct ec_stripe_b ...@@ -983,8 +983,8 @@ static int ec_stripe_update_bucket(struct btree_trans *trans, struct ec_stripe_b
while (1) { while (1) {
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOCHECK_RW| BCH_TRANS_COMMIT_no_check_rw|
BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_no_enospc,
ec_stripe_update_extent(trans, bucket_pos, bucket.gen, ec_stripe_update_extent(trans, bucket_pos, bucket.gen,
s, &bp_pos)); s, &bp_pos));
if (ret) if (ret)
...@@ -1121,8 +1121,8 @@ static void ec_stripe_create(struct ec_stripe_new *s) ...@@ -1121,8 +1121,8 @@ static void ec_stripe_create(struct ec_stripe_new *s)
} }
ret = bch2_trans_do(c, &s->res, NULL, ret = bch2_trans_do(c, &s->res, NULL,
BTREE_INSERT_NOCHECK_RW| BCH_TRANS_COMMIT_no_check_rw|
BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_no_enospc,
ec_stripe_key_update(trans, ec_stripe_key_update(trans,
bkey_i_to_stripe(&s->new_stripe.key), bkey_i_to_stripe(&s->new_stripe.key),
!s->have_existing_stripe)); !s->have_existing_stripe));
......
...@@ -93,7 +93,7 @@ int __must_check bch2_write_inode(struct bch_fs *c, ...@@ -93,7 +93,7 @@ int __must_check bch2_write_inode(struct bch_fs *c,
BTREE_ITER_INTENT) ?: BTREE_ITER_INTENT) ?:
(set ? set(trans, inode, &inode_u, p) : 0) ?: (set ? set(trans, inode, &inode_u, p) : 0) ?:
bch2_inode_write(trans, &iter, &inode_u) ?: bch2_inode_write(trans, &iter, &inode_u) ?:
bch2_trans_commit(trans, NULL, NULL, BTREE_INSERT_NOFAIL); bch2_trans_commit(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc);
/* /*
* the btree node lock protects inode->ei_inode, not ei_update_lock; * the btree node lock protects inode->ei_inode, not ei_update_lock;
...@@ -455,7 +455,7 @@ int __bch2_unlink(struct inode *vdir, struct dentry *dentry, ...@@ -455,7 +455,7 @@ int __bch2_unlink(struct inode *vdir, struct dentry *dentry,
bch2_lock_inodes(INODE_UPDATE_LOCK, dir, inode); bch2_lock_inodes(INODE_UPDATE_LOCK, dir, inode);
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_no_enospc,
bch2_unlink_trans(trans, bch2_unlink_trans(trans,
inode_inum(dir), &dir_u, inode_inum(dir), &dir_u,
&inode_u, &dentry->d_name, &inode_u, &dentry->d_name,
...@@ -729,7 +729,7 @@ int bch2_setattr_nonsize(struct mnt_idmap *idmap, ...@@ -729,7 +729,7 @@ int bch2_setattr_nonsize(struct mnt_idmap *idmap,
ret = bch2_inode_write(trans, &inode_iter, &inode_u) ?: ret = bch2_inode_write(trans, &inode_iter, &inode_u) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
btree_err: btree_err:
bch2_trans_iter_exit(trans, &inode_iter); bch2_trans_iter_exit(trans, &inode_iter);
......
...@@ -208,8 +208,8 @@ static int fsck_write_inode(struct btree_trans *trans, ...@@ -208,8 +208,8 @@ static int fsck_write_inode(struct btree_trans *trans,
u32 snapshot) u32 snapshot)
{ {
int ret = commit_do(trans, NULL, NULL, int ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW, BCH_TRANS_COMMIT_lazy_rw,
__write_inode(trans, inode, snapshot)); __write_inode(trans, inode, snapshot));
if (ret) if (ret)
bch_err_fn(trans->c, ret); bch_err_fn(trans->c, ret);
...@@ -354,8 +354,8 @@ static int reattach_inode(struct btree_trans *trans, ...@@ -354,8 +354,8 @@ static int reattach_inode(struct btree_trans *trans,
u32 inode_snapshot) u32 inode_snapshot)
{ {
int ret = commit_do(trans, NULL, NULL, int ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_LAZY_RW| BCH_TRANS_COMMIT_lazy_rw|
BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_no_enospc,
__reattach_inode(trans, inode, inode_snapshot)); __reattach_inode(trans, inode, inode_snapshot));
bch_err_msg(trans->c, ret, "reattaching inode %llu", inode->bi_inum); bch_err_msg(trans->c, ret, "reattaching inode %llu", inode->bi_inum);
return ret; return ret;
...@@ -757,8 +757,8 @@ static int hash_redo_key(struct btree_trans *trans, ...@@ -757,8 +757,8 @@ static int hash_redo_key(struct btree_trans *trans,
BCH_HASH_SET_MUST_CREATE, BCH_HASH_SET_MUST_CREATE,
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?: BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW); BCH_TRANS_COMMIT_lazy_rw);
} }
static int hash_check_key(struct btree_trans *trans, static int hash_check_key(struct btree_trans *trans,
...@@ -1015,7 +1015,7 @@ int bch2_check_inodes(struct bch_fs *c) ...@@ -1015,7 +1015,7 @@ int bch2_check_inodes(struct bch_fs *c)
ret = for_each_btree_key_commit(trans, iter, BTREE_ID_inodes, ret = for_each_btree_key_commit(trans, iter, BTREE_ID_inodes,
POS_MIN, POS_MIN,
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
NULL, NULL, BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
check_inode(trans, &iter, k, &prev, &s, full)); check_inode(trans, &iter, k, &prev, &s, full));
snapshots_seen_exit(&s); snapshots_seen_exit(&s);
...@@ -1230,7 +1230,7 @@ static int overlapping_extents_found(struct btree_trans *trans, ...@@ -1230,7 +1230,7 @@ static int overlapping_extents_found(struct btree_trans *trans,
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE,
k1, k2) ?: k1, k2) ?:
bch2_trans_commit(trans, &res, NULL, bch2_trans_commit(trans, &res, NULL,
BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc);
bch2_disk_reservation_put(c, &res); bch2_disk_reservation_put(c, &res);
if (ret) if (ret)
...@@ -1469,7 +1469,7 @@ int bch2_check_extents(struct bch_fs *c) ...@@ -1469,7 +1469,7 @@ int bch2_check_extents(struct bch_fs *c)
POS(BCACHEFS_ROOT_INO, 0), POS(BCACHEFS_ROOT_INO, 0),
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
&res, NULL, &res, NULL,
BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, ({ BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc, ({
bch2_disk_reservation_put(c, &res); bch2_disk_reservation_put(c, &res);
check_extent(trans, &iter, k, &w, &s, &extent_ends) ?: check_extent(trans, &iter, k, &w, &s, &extent_ends) ?:
check_extent_overbig(trans, &iter, k); check_extent_overbig(trans, &iter, k);
...@@ -1498,7 +1498,7 @@ int bch2_check_indirect_extents(struct bch_fs *c) ...@@ -1498,7 +1498,7 @@ int bch2_check_indirect_extents(struct bch_fs *c)
POS_MIN, POS_MIN,
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
&res, NULL, &res, NULL,
BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, ({ BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc, ({
bch2_disk_reservation_put(c, &res); bch2_disk_reservation_put(c, &res);
check_extent_overbig(trans, &iter, k); check_extent_overbig(trans, &iter, k);
})); }));
...@@ -1871,7 +1871,7 @@ int bch2_check_dirents(struct bch_fs *c) ...@@ -1871,7 +1871,7 @@ int bch2_check_dirents(struct bch_fs *c)
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS,
k, k,
NULL, NULL, NULL, NULL,
BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
check_dirent(trans, &iter, k, &hash_info, &dir, &target, &s)); check_dirent(trans, &iter, k, &hash_info, &dir, &target, &s));
bch2_trans_put(trans); bch2_trans_put(trans);
...@@ -1935,7 +1935,7 @@ int bch2_check_xattrs(struct bch_fs *c) ...@@ -1935,7 +1935,7 @@ int bch2_check_xattrs(struct bch_fs *c)
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS,
k, k,
NULL, NULL, NULL, NULL,
BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
check_xattr(trans, &iter, k, &hash_info, &inode))); check_xattr(trans, &iter, k, &hash_info, &inode)));
bch_err_fn(c, ret); bch_err_fn(c, ret);
return ret; return ret;
...@@ -1966,8 +1966,8 @@ static int check_root_trans(struct btree_trans *trans) ...@@ -1966,8 +1966,8 @@ static int check_root_trans(struct btree_trans *trans)
root_subvol.v.snapshot = cpu_to_le32(snapshot); root_subvol.v.snapshot = cpu_to_le32(snapshot);
root_subvol.v.inode = cpu_to_le64(inum); root_subvol.v.inode = cpu_to_le64(inum);
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW, BCH_TRANS_COMMIT_lazy_rw,
bch2_btree_insert_trans(trans, BTREE_ID_subvolumes, bch2_btree_insert_trans(trans, BTREE_ID_subvolumes,
&root_subvol.k_i, 0)); &root_subvol.k_i, 0));
bch_err_msg(c, ret, "writing root subvol"); bch_err_msg(c, ret, "writing root subvol");
...@@ -2003,8 +2003,8 @@ int bch2_check_root(struct bch_fs *c) ...@@ -2003,8 +2003,8 @@ int bch2_check_root(struct bch_fs *c)
int ret; int ret;
ret = bch2_trans_do(c, NULL, NULL, ret = bch2_trans_do(c, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW, BCH_TRANS_COMMIT_lazy_rw,
check_root_trans(trans)); check_root_trans(trans));
bch_err_fn(c, ret); bch_err_fn(c, ret);
return ret; return ret;
...@@ -2133,8 +2133,8 @@ static int check_path(struct btree_trans *trans, ...@@ -2133,8 +2133,8 @@ static int check_path(struct btree_trans *trans,
return 0; return 0;
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW, BCH_TRANS_COMMIT_lazy_rw,
remove_backpointer(trans, inode)); remove_backpointer(trans, inode));
if (ret) { if (ret) {
bch_err(c, "error removing dirent: %i", ret); bch_err(c, "error removing dirent: %i", ret);
...@@ -2415,7 +2415,7 @@ static int check_nlinks_update_hardlinks(struct bch_fs *c, ...@@ -2415,7 +2415,7 @@ static int check_nlinks_update_hardlinks(struct bch_fs *c,
for_each_btree_key_commit(trans, iter, BTREE_ID_inodes, for_each_btree_key_commit(trans, iter, BTREE_ID_inodes,
POS(0, range_start), POS(0, range_start),
BTREE_ITER_INTENT|BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, BTREE_ITER_INTENT|BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
NULL, NULL, BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
check_nlinks_update_inode(trans, &iter, k, links, &idx, range_end))); check_nlinks_update_inode(trans, &iter, k, links, &idx, range_end)));
if (ret < 0) { if (ret < 0) {
bch_err(c, "error in fsck walking inodes: %s", bch2_err_str(ret)); bch_err(c, "error in fsck walking inodes: %s", bch2_err_str(ret));
...@@ -2500,7 +2500,7 @@ int bch2_fix_reflink_p(struct bch_fs *c) ...@@ -2500,7 +2500,7 @@ int bch2_fix_reflink_p(struct bch_fs *c)
BTREE_ID_extents, POS_MIN, BTREE_ID_extents, POS_MIN,
BTREE_ITER_INTENT|BTREE_ITER_PREFETCH| BTREE_ITER_INTENT|BTREE_ITER_PREFETCH|
BTREE_ITER_ALL_SNAPSHOTS, k, BTREE_ITER_ALL_SNAPSHOTS, k,
NULL, NULL, BTREE_INSERT_NOFAIL|BTREE_INSERT_LAZY_RW, NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw,
fix_reflink_p_key(trans, &iter, k))); fix_reflink_p_key(trans, &iter, k)));
bch_err_fn(c, ret); bch_err_fn(c, ret);
return ret; return ret;
......
...@@ -831,7 +831,7 @@ static int bch2_inode_delete_keys(struct btree_trans *trans, ...@@ -831,7 +831,7 @@ static int bch2_inode_delete_keys(struct btree_trans *trans,
ret = bch2_trans_update(trans, &iter, &delete, 0) ?: ret = bch2_trans_update(trans, &iter, &delete, 0) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
err: err:
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
break; break;
...@@ -894,7 +894,7 @@ int bch2_inode_rm(struct bch_fs *c, subvol_inum inum) ...@@ -894,7 +894,7 @@ int bch2_inode_rm(struct bch_fs *c, subvol_inum inum)
ret = bch2_trans_update(trans, &iter, &delete.k_i, 0) ?: ret = bch2_trans_update(trans, &iter, &delete.k_i, 0) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
err: err:
bch2_trans_iter_exit(trans, &iter); bch2_trans_iter_exit(trans, &iter);
if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
...@@ -1058,7 +1058,7 @@ int bch2_inode_rm_snapshot(struct btree_trans *trans, u64 inum, u32 snapshot) ...@@ -1058,7 +1058,7 @@ int bch2_inode_rm_snapshot(struct btree_trans *trans, u64 inum, u32 snapshot)
ret = bch2_trans_update(trans, &iter, &delete.k_i, 0) ?: ret = bch2_trans_update(trans, &iter, &delete.k_i, 0) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
err: err:
bch2_trans_iter_exit(trans, &iter); bch2_trans_iter_exit(trans, &iter);
if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (bch2_err_matches(ret, BCH_ERR_transaction_restart))
...@@ -1175,8 +1175,8 @@ int bch2_delete_dead_inodes(struct bch_fs *c) ...@@ -1175,8 +1175,8 @@ int bch2_delete_dead_inodes(struct bch_fs *c)
for_each_btree_key(trans, iter, BTREE_ID_deleted_inodes, POS_MIN, for_each_btree_key(trans, iter, BTREE_ID_deleted_inodes, POS_MIN,
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, ret) { BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, ret) {
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_LAZY_RW, BCH_TRANS_COMMIT_lazy_rw,
may_delete_deleted_inode(trans, &iter, k.k->p, &need_another_pass)); may_delete_deleted_inode(trans, &iter, k.k->p, &need_another_pass));
if (ret < 0) if (ret < 0)
break; break;
......
...@@ -256,7 +256,7 @@ static int __bch2_resume_logged_op_truncate(struct btree_trans *trans, ...@@ -256,7 +256,7 @@ static int __bch2_resume_logged_op_truncate(struct btree_trans *trans,
u64 new_i_size = le64_to_cpu(op->v.new_i_size); u64 new_i_size = le64_to_cpu(op->v.new_i_size);
int ret; int ret;
ret = commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
truncate_set_isize(trans, inum, new_i_size)); truncate_set_isize(trans, inum, new_i_size));
if (ret) if (ret)
goto err; goto err;
...@@ -378,7 +378,7 @@ case LOGGED_OP_FINSERT_start: ...@@ -378,7 +378,7 @@ case LOGGED_OP_FINSERT_start:
op->v.state = LOGGED_OP_FINSERT_shift_extents; op->v.state = LOGGED_OP_FINSERT_shift_extents;
if (insert) { if (insert) {
ret = commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
adjust_i_size(trans, inum, src_offset, len) ?: adjust_i_size(trans, inum, src_offset, len) ?:
bch2_logged_op_update(trans, &op->k_i)); bch2_logged_op_update(trans, &op->k_i));
if (ret) if (ret)
...@@ -390,7 +390,7 @@ case LOGGED_OP_FINSERT_start: ...@@ -390,7 +390,7 @@ case LOGGED_OP_FINSERT_start:
if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart)) if (ret && !bch2_err_matches(ret, BCH_ERR_transaction_restart))
goto err; goto err;
ret = commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_logged_op_update(trans, &op->k_i)); bch2_logged_op_update(trans, &op->k_i));
} }
...@@ -455,7 +455,7 @@ case LOGGED_OP_FINSERT_shift_extents: ...@@ -455,7 +455,7 @@ case LOGGED_OP_FINSERT_shift_extents:
bch2_btree_insert_trans(trans, BTREE_ID_extents, &delete, 0) ?: bch2_btree_insert_trans(trans, BTREE_ID_extents, &delete, 0) ?:
bch2_btree_insert_trans(trans, BTREE_ID_extents, copy, 0) ?: bch2_btree_insert_trans(trans, BTREE_ID_extents, copy, 0) ?:
bch2_logged_op_update(trans, &op->k_i) ?: bch2_logged_op_update(trans, &op->k_i) ?:
bch2_trans_commit(trans, &disk_res, NULL, BTREE_INSERT_NOFAIL); bch2_trans_commit(trans, &disk_res, NULL, BCH_TRANS_COMMIT_no_enospc);
btree_err: btree_err:
bch2_disk_reservation_put(c, &disk_res); bch2_disk_reservation_put(c, &disk_res);
...@@ -470,12 +470,12 @@ case LOGGED_OP_FINSERT_shift_extents: ...@@ -470,12 +470,12 @@ case LOGGED_OP_FINSERT_shift_extents:
op->v.state = LOGGED_OP_FINSERT_finish; op->v.state = LOGGED_OP_FINSERT_finish;
if (!insert) { if (!insert) {
ret = commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
adjust_i_size(trans, inum, src_offset, shift) ?: adjust_i_size(trans, inum, src_offset, shift) ?:
bch2_logged_op_update(trans, &op->k_i)); bch2_logged_op_update(trans, &op->k_i));
} else { } else {
/* We need an inode update to update bi_journal_seq for fsync: */ /* We need an inode update to update bi_journal_seq for fsync: */
ret = commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
adjust_i_size(trans, inum, 0, 0) ?: adjust_i_size(trans, inum, 0, 0) ?:
bch2_logged_op_update(trans, &op->k_i)); bch2_logged_op_update(trans, &op->k_i));
} }
......
...@@ -526,7 +526,7 @@ static int __bch2_rbio_narrow_crcs(struct btree_trans *trans, ...@@ -526,7 +526,7 @@ static int __bch2_rbio_narrow_crcs(struct btree_trans *trans,
static noinline void bch2_rbio_narrow_crcs(struct bch_read_bio *rbio) static noinline void bch2_rbio_narrow_crcs(struct bch_read_bio *rbio)
{ {
bch2_trans_do(rbio->c, NULL, NULL, BTREE_INSERT_NOFAIL, bch2_trans_do(rbio->c, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
__bch2_rbio_narrow_crcs(trans, rbio)); __bch2_rbio_narrow_crcs(trans, rbio));
} }
......
...@@ -316,8 +316,8 @@ int bch2_extent_update(struct btree_trans *trans, ...@@ -316,8 +316,8 @@ int bch2_extent_update(struct btree_trans *trans,
i_sectors_delta) ?: i_sectors_delta) ?:
bch2_trans_update(trans, iter, k, 0) ?: bch2_trans_update(trans, iter, k, 0) ?:
bch2_trans_commit(trans, disk_res, NULL, bch2_trans_commit(trans, disk_res, NULL,
BTREE_INSERT_NOCHECK_RW| BCH_TRANS_COMMIT_no_check_rw|
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
if (unlikely(ret)) if (unlikely(ret))
return ret; return ret;
...@@ -1176,7 +1176,7 @@ static void bch2_nocow_write_convert_unwritten(struct bch_write_op *op) ...@@ -1176,7 +1176,7 @@ static void bch2_nocow_write_convert_unwritten(struct bch_write_op *op)
ret = for_each_btree_key_upto_commit(trans, iter, BTREE_ID_extents, ret = for_each_btree_key_upto_commit(trans, iter, BTREE_ID_extents,
bkey_start_pos(&orig->k), orig->k.p, bkey_start_pos(&orig->k), orig->k.p,
BTREE_ITER_INTENT, k, BTREE_ITER_INTENT, k,
NULL, NULL, BTREE_INSERT_NOFAIL, ({ NULL, NULL, BCH_TRANS_COMMIT_no_enospc, ({
bch2_nocow_write_convert_one_unwritten(trans, &iter, orig, k, op->new_i_size); bch2_nocow_write_convert_one_unwritten(trans, &iter, orig, k, op->new_i_size);
})); }));
......
...@@ -85,13 +85,13 @@ static int __bch2_logged_op_start(struct btree_trans *trans, struct bkey_i *k) ...@@ -85,13 +85,13 @@ static int __bch2_logged_op_start(struct btree_trans *trans, struct bkey_i *k)
int bch2_logged_op_start(struct btree_trans *trans, struct bkey_i *k) int bch2_logged_op_start(struct btree_trans *trans, struct bkey_i *k)
{ {
return commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, return commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
__bch2_logged_op_start(trans, k)); __bch2_logged_op_start(trans, k));
} }
void bch2_logged_op_finish(struct btree_trans *trans, struct bkey_i *k) void bch2_logged_op_finish(struct btree_trans *trans, struct bkey_i *k)
{ {
int ret = commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, int ret = commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_btree_delete(trans, BTREE_ID_logged_ops, k->k.p, 0)); bch2_btree_delete(trans, BTREE_ID_logged_ops, k->k.p, 0));
/* /*
* This needs to be a fatal error because we've left an unfinished * This needs to be a fatal error because we've left an unfinished
......
...@@ -155,7 +155,7 @@ int bch2_check_lrus(struct bch_fs *c) ...@@ -155,7 +155,7 @@ int bch2_check_lrus(struct bch_fs *c)
ret = bch2_trans_run(c, ret = bch2_trans_run(c,
for_each_btree_key_commit(trans, iter, for_each_btree_key_commit(trans, iter,
BTREE_ID_lru, POS_MIN, BTREE_ITER_PREFETCH, k, BTREE_ID_lru, POS_MIN, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_NOFAIL|BTREE_INSERT_LAZY_RW, NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw,
bch2_check_lru_key(trans, &iter, k, &last_flushed_pos))); bch2_check_lru_key(trans, &iter, k, &last_flushed_pos)));
if (ret) if (ret)
bch_err_fn(c, ret); bch_err_fn(c, ret);
......
...@@ -90,7 +90,7 @@ static int bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags) ...@@ -90,7 +90,7 @@ static int bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
ret = for_each_btree_key_commit(trans, iter, id, POS_MIN, ret = for_each_btree_key_commit(trans, iter, id, POS_MIN,
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
NULL, NULL, BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_dev_usrdata_drop_key(trans, &iter, k, dev_idx, flags)); bch2_dev_usrdata_drop_key(trans, &iter, k, dev_idx, flags));
if (ret) if (ret)
break; break;
......
...@@ -69,7 +69,7 @@ static int __bch2_set_rebalance_needs_scan(struct btree_trans *trans, u64 inum) ...@@ -69,7 +69,7 @@ static int __bch2_set_rebalance_needs_scan(struct btree_trans *trans, u64 inum)
int bch2_set_rebalance_needs_scan(struct bch_fs *c, u64 inum) int bch2_set_rebalance_needs_scan(struct bch_fs *c, u64 inum)
{ {
int ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_NOFAIL|BTREE_INSERT_LAZY_RW, int ret = bch2_trans_do(c, NULL, NULL, BCH_TRANS_COMMIT_no_enospc|BCH_TRANS_COMMIT_lazy_rw,
__bch2_set_rebalance_needs_scan(trans, inum)); __bch2_set_rebalance_needs_scan(trans, inum));
rebalance_wakeup(c); rebalance_wakeup(c);
return ret; return ret;
...@@ -125,7 +125,7 @@ static int bch2_bkey_clear_needs_rebalance(struct btree_trans *trans, ...@@ -125,7 +125,7 @@ static int bch2_bkey_clear_needs_rebalance(struct btree_trans *trans,
extent_entry_drop(bkey_i_to_s(n), extent_entry_drop(bkey_i_to_s(n),
(void *) bch2_bkey_rebalance_opts(bkey_i_to_s_c(n))); (void *) bch2_bkey_rebalance_opts(bkey_i_to_s_c(n)));
return bch2_trans_commit(trans, NULL, NULL, BTREE_INSERT_NOFAIL); return bch2_trans_commit(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc);
} }
static struct bkey_s_c next_rebalance_extent(struct btree_trans *trans, static struct bkey_s_c next_rebalance_extent(struct btree_trans *trans,
...@@ -273,7 +273,7 @@ static int do_rebalance_scan(struct moving_context *ctxt, u64 inum, u64 cookie) ...@@ -273,7 +273,7 @@ static int do_rebalance_scan(struct moving_context *ctxt, u64 inum, u64 cookie)
r->state = BCH_REBALANCE_scanning; r->state = BCH_REBALANCE_scanning;
ret = __bch2_move_data(ctxt, r->scan_start, r->scan_end, rebalance_pred, NULL) ?: ret = __bch2_move_data(ctxt, r->scan_start, r->scan_end, rebalance_pred, NULL) ?:
commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_clear_rebalance_needs_scan(trans, inum, cookie)); bch2_clear_rebalance_needs_scan(trans, inum, cookie));
bch2_move_stats_exit(&r->scan_stats, trans->c); bch2_move_stats_exit(&r->scan_stats, trans->c);
......
...@@ -175,9 +175,9 @@ static int bch2_journal_replay(struct bch_fs *c) ...@@ -175,9 +175,9 @@ static int bch2_journal_replay(struct bch_fs *c)
/* Skip fastpath if we're low on space in the journal */ /* Skip fastpath if we're low on space in the journal */
ret = c->journal.watermark ? -1 : ret = c->journal.watermark ? -1 :
commit_do(trans, NULL, NULL, commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
BTREE_INSERT_JOURNAL_RECLAIM| BCH_TRANS_COMMIT_journal_reclaim|
(!k->allocated ? BTREE_INSERT_JOURNAL_REPLAY : 0), (!k->allocated ? BCH_TRANS_COMMIT_no_journal_res : 0),
bch2_journal_replay_key(trans, k)); bch2_journal_replay_key(trans, k));
BUG_ON(!ret && !k->overwritten); BUG_ON(!ret && !k->overwritten);
if (ret) { if (ret) {
...@@ -203,9 +203,9 @@ static int bch2_journal_replay(struct bch_fs *c) ...@@ -203,9 +203,9 @@ static int bch2_journal_replay(struct bch_fs *c)
replay_now_at(j, k->journal_seq); replay_now_at(j, k->journal_seq);
ret = commit_do(trans, NULL, NULL, ret = commit_do(trans, NULL, NULL,
BTREE_INSERT_NOFAIL| BCH_TRANS_COMMIT_no_enospc|
(!k->allocated (!k->allocated
? BTREE_INSERT_JOURNAL_REPLAY|BCH_WATERMARK_reclaim ? BCH_TRANS_COMMIT_no_journal_res|BCH_WATERMARK_reclaim
: 0), : 0),
bch2_journal_replay_key(trans, k)); bch2_journal_replay_key(trans, k));
bch_err_msg(c, ret, "while replaying key at btree %s level %u:", bch_err_msg(c, ret, "while replaying key at btree %s level %u:",
...@@ -506,7 +506,7 @@ static int __bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans) ...@@ -506,7 +506,7 @@ static int __bch2_fs_upgrade_for_subvolumes(struct btree_trans *trans)
noinline_for_stack noinline_for_stack
static int bch2_fs_upgrade_for_subvolumes(struct bch_fs *c) static int bch2_fs_upgrade_for_subvolumes(struct bch_fs *c)
{ {
int ret = bch2_trans_do(c, NULL, NULL, BTREE_INSERT_LAZY_RW, int ret = bch2_trans_do(c, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw,
__bch2_fs_upgrade_for_subvolumes(trans)); __bch2_fs_upgrade_for_subvolumes(trans));
if (ret) if (ret)
bch_err_fn(c, ret); bch_err_fn(c, ret);
......
...@@ -398,7 +398,7 @@ s64 bch2_remap_range(struct bch_fs *c, ...@@ -398,7 +398,7 @@ s64 bch2_remap_range(struct bch_fs *c,
inode_u.bi_size = new_i_size; inode_u.bi_size = new_i_size;
ret2 = bch2_inode_write(trans, &inode_iter, &inode_u) ?: ret2 = bch2_inode_write(trans, &inode_iter, &inode_u) ?:
bch2_trans_commit(trans, NULL, NULL, bch2_trans_commit(trans, NULL, NULL,
BTREE_INSERT_NOFAIL); BCH_TRANS_COMMIT_no_enospc);
} }
bch2_trans_iter_exit(trans, &inode_iter); bch2_trans_iter_exit(trans, &inode_iter);
......
...@@ -590,7 +590,7 @@ int bch2_check_snapshot_trees(struct bch_fs *c) ...@@ -590,7 +590,7 @@ int bch2_check_snapshot_trees(struct bch_fs *c)
for_each_btree_key_commit(trans, iter, for_each_btree_key_commit(trans, iter,
BTREE_ID_snapshot_trees, POS_MIN, BTREE_ID_snapshot_trees, POS_MIN,
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
check_snapshot_tree(trans, &iter, k))); check_snapshot_tree(trans, &iter, k)));
if (ret) if (ret)
...@@ -868,7 +868,7 @@ int bch2_check_snapshots(struct bch_fs *c) ...@@ -868,7 +868,7 @@ int bch2_check_snapshots(struct bch_fs *c)
for_each_btree_key_reverse_commit(trans, iter, for_each_btree_key_reverse_commit(trans, iter,
BTREE_ID_snapshots, POS_MAX, BTREE_ID_snapshots, POS_MAX,
BTREE_ITER_PREFETCH, k, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
check_snapshot(trans, &iter, k))); check_snapshot(trans, &iter, k)));
if (ret) if (ret)
bch_err_fn(c, ret); bch_err_fn(c, ret);
...@@ -1449,12 +1449,12 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1449,12 +1449,12 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
ret = for_each_btree_key_commit(trans, iter, ret = for_each_btree_key_commit(trans, iter,
id, POS_MIN, id, POS_MIN,
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
&res, NULL, BTREE_INSERT_NOFAIL, &res, NULL, BCH_TRANS_COMMIT_no_enospc,
snapshot_delete_key(trans, &iter, k, &deleted, &equiv_seen, &last_pos)) ?: snapshot_delete_key(trans, &iter, k, &deleted, &equiv_seen, &last_pos)) ?:
for_each_btree_key_commit(trans, iter, for_each_btree_key_commit(trans, iter,
id, POS_MIN, id, POS_MIN,
BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k, BTREE_ITER_PREFETCH|BTREE_ITER_ALL_SNAPSHOTS, k,
&res, NULL, BTREE_INSERT_NOFAIL, &res, NULL, BCH_TRANS_COMMIT_no_enospc,
move_key_to_correct_snapshot(trans, &iter, k)); move_key_to_correct_snapshot(trans, &iter, k));
bch2_disk_reservation_put(c, &res); bch2_disk_reservation_put(c, &res);
...@@ -1489,7 +1489,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c) ...@@ -1489,7 +1489,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
*/ */
ret = for_each_btree_key_commit(trans, iter, BTREE_ID_snapshots, POS_MIN, ret = for_each_btree_key_commit(trans, iter, BTREE_ID_snapshots, POS_MIN,
BTREE_ITER_INTENT, k, BTREE_ITER_INTENT, k,
NULL, NULL, BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_fix_child_of_deleted_snapshot(trans, &iter, k, &deleted_interior)); bch2_fix_child_of_deleted_snapshot(trans, &iter, k, &deleted_interior));
if (ret) if (ret)
goto err_create_lock; goto err_create_lock;
......
...@@ -89,7 +89,7 @@ int bch2_check_subvols(struct bch_fs *c) ...@@ -89,7 +89,7 @@ int bch2_check_subvols(struct bch_fs *c)
ret = bch2_trans_run(c, ret = bch2_trans_run(c,
for_each_btree_key_commit(trans, iter, for_each_btree_key_commit(trans, iter,
BTREE_ID_subvolumes, POS_MIN, BTREE_ITER_PREFETCH, k, BTREE_ID_subvolumes, POS_MIN, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_LAZY_RW|BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_lazy_rw|BCH_TRANS_COMMIT_no_enospc,
check_subvol(trans, &iter, k))); check_subvol(trans, &iter, k)));
if (ret) if (ret)
bch_err_fn(c, ret); bch_err_fn(c, ret);
...@@ -237,7 +237,7 @@ static int bch2_subvolumes_reparent(struct btree_trans *trans, u32 subvolid_to_d ...@@ -237,7 +237,7 @@ static int bch2_subvolumes_reparent(struct btree_trans *trans, u32 subvolid_to_d
BTREE_ITER_CACHED, &s)) ?: BTREE_ITER_CACHED, &s)) ?:
for_each_btree_key_commit(trans, iter, for_each_btree_key_commit(trans, iter,
BTREE_ID_subvolumes, POS_MIN, BTREE_ITER_PREFETCH, k, BTREE_ID_subvolumes, POS_MIN, BTREE_ITER_PREFETCH, k,
NULL, NULL, BTREE_INSERT_NOFAIL, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
bch2_subvolume_reparent(trans, &iter, k, bch2_subvolume_reparent(trans, &iter, k,
subvolid_to_delete, le32_to_cpu(s.parent))); subvolid_to_delete, le32_to_cpu(s.parent)));
} }
...@@ -274,7 +274,7 @@ static int __bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid) ...@@ -274,7 +274,7 @@ static int __bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid)
static int bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid) static int bch2_subvolume_delete(struct btree_trans *trans, u32 subvolid)
{ {
return bch2_subvolumes_reparent(trans, subvolid) ?: return bch2_subvolumes_reparent(trans, subvolid) ?:
commit_do(trans, NULL, NULL, BTREE_INSERT_NOFAIL, commit_do(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc,
__bch2_subvolume_delete(trans, subvolid)); __bch2_subvolume_delete(trans, subvolid));
} }
......
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