Commit 5f8077cc authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Kill BTREE_ITER_SET_POS_AFTER_COMMIT

BTREE_ITER_SET_POS_AFTER_COMMIT is used internally to automagically
advance extent btree iterators on sucessful commit.

But with the upcomnig btree_path patch it's getting more awkward to
support, and it adds overhead to core data structures that's only used
in a few places, and can be easily done by the caller instead.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 638c6ff9
......@@ -2347,7 +2347,6 @@ static void btree_iter_copy(struct btree_trans *trans, struct btree_iter *dst,
__btree_lock_want(dst, i));
dst->flags &= ~BTREE_ITER_KEEP_UNTIL_COMMIT;
dst->flags &= ~BTREE_ITER_SET_POS_AFTER_COMMIT;
trans->iters_sorted = false;
}
......@@ -2564,8 +2563,7 @@ void bch2_trans_begin(struct btree_trans *trans)
struct btree_iter *iter;
trans_for_each_iter(trans, iter)
iter->flags &= ~(BTREE_ITER_KEEP_UNTIL_COMMIT|
BTREE_ITER_SET_POS_AFTER_COMMIT);
iter->flags &= ~BTREE_ITER_KEEP_UNTIL_COMMIT;
/*
* XXX: we shouldn't be doing this if the transaction was restarted, but
......
......@@ -211,11 +211,10 @@ enum btree_iter_type {
#define BTREE_ITER_IS_EXTENTS (1 << 6)
#define BTREE_ITER_NOT_EXTENTS (1 << 7)
#define BTREE_ITER_ERROR (1 << 8)
#define BTREE_ITER_SET_POS_AFTER_COMMIT (1 << 9)
#define BTREE_ITER_CACHED_NOFILL (1 << 10)
#define BTREE_ITER_CACHED_NOCREATE (1 << 11)
#define BTREE_ITER_WITH_UPDATES (1 << 12)
#define BTREE_ITER_ALL_SNAPSHOTS (1 << 13)
#define BTREE_ITER_CACHED_NOFILL (1 << 9)
#define BTREE_ITER_CACHED_NOCREATE (1 << 10)
#define BTREE_ITER_WITH_UPDATES (1 << 11)
#define BTREE_ITER_ALL_SNAPSHOTS (1 << 12)
enum btree_iter_uptodate {
BTREE_ITER_UPTODATE = 0,
......@@ -256,7 +255,6 @@ struct btree_iter {
struct bpos pos;
struct bpos real_pos;
struct bpos pos_after_commit;
enum btree_id btree_id:4;
enum btree_iter_uptodate uptodate:3;
......
......@@ -742,7 +742,6 @@ bch2_trans_commit_get_rw_cold(struct btree_trans *trans)
int __bch2_trans_commit(struct btree_trans *trans)
{
struct btree_insert_entry *i = NULL;
struct btree_iter *iter;
bool trans_trigger_run;
unsigned u64s;
int ret = 0;
......@@ -840,11 +839,6 @@ int __bch2_trans_commit(struct btree_trans *trans)
if (ret)
goto err;
trans_for_each_iter(trans, iter)
if (btree_iter_live(trans, iter) &&
(iter->flags & BTREE_ITER_SET_POS_AFTER_COMMIT))
bch2_btree_iter_set_pos(iter, iter->pos_after_commit);
out:
bch2_journal_preres_put(&trans->c->journal, &trans->journal_preres);
......@@ -920,9 +914,6 @@ static int bch2_trans_update_extent(struct btree_trans *trans,
enum btree_id btree_id = orig_iter->btree_id;
int ret = 0, compressed_sectors;
orig_iter->pos_after_commit = insert->k.p;
orig_iter->flags |= BTREE_ITER_SET_POS_AFTER_COMMIT;
iter = bch2_trans_get_iter(trans, btree_id, start,
BTREE_ITER_INTENT|
BTREE_ITER_WITH_UPDATES|
......
......@@ -824,6 +824,7 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
struct bkey_s_c k;
struct bkey_s_extent e;
struct bkey_buf sk;
struct bpos next_pos;
int ret = 0, dev, block;
bch2_bkey_buf_init(&sk);
......@@ -863,10 +864,14 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
extent_stripe_ptr_add(e, s, ec_ptr, block);
bch2_btree_iter_set_pos(iter, bkey_start_pos(&sk.k->k));
next_pos = sk.k->k.p;
ret = bch2_btree_iter_traverse(iter) ?:
bch2_trans_update(&trans, iter, sk.k, 0) ?:
bch2_trans_commit(&trans, NULL, NULL,
BTREE_INSERT_NOFAIL);
if (!ret)
bch2_btree_iter_set_pos(iter, next_pos);
if (ret == -EINTR)
ret = 0;
if (ret)
......
......@@ -276,6 +276,7 @@ int bch2_extent_update(struct btree_trans *trans,
{
/* this must live until after bch2_trans_commit(): */
struct bkey_inode_buf inode_p;
struct bpos next_pos;
bool extending = false, usage_increasing;
s64 i_sectors_delta = 0, disk_sectors_delta = 0;
int ret;
......@@ -354,6 +355,8 @@ int bch2_extent_update(struct btree_trans *trans,
return ret;
}
next_pos = k->k.p;
ret = bch2_trans_update(trans, iter, k, 0) ?:
bch2_trans_commit(trans, disk_res, journal_seq,
BTREE_INSERT_NOCHECK_RW|
......@@ -362,6 +365,8 @@ int bch2_extent_update(struct btree_trans *trans,
if (ret)
return ret;
bch2_btree_iter_set_pos(iter, next_pos);
if (i_sectors_delta_total)
*i_sectors_delta_total += i_sectors_delta;
return 0;
......
......@@ -79,6 +79,7 @@ int bch2_migrate_index_update(struct bch_write_op *op)
struct bkey_i_extent *new;
const union bch_extent_entry *entry;
struct extent_ptr_decoded p;
struct bpos next_pos;
bool did_work = false;
bool extending = false, should_check_enospc;
s64 i_sectors_delta = 0, disk_sectors_delta = 0;
......@@ -162,14 +163,18 @@ int bch2_migrate_index_update(struct bch_write_op *op)
goto out;
}
next_pos = insert->k.p;
ret = bch2_trans_update(&trans, iter, insert, 0) ?:
bch2_trans_commit(&trans, &op->res,
op_journal_seq(op),
BTREE_INSERT_NOFAIL|
m->data_opts.btree_insert_flags);
err:
if (!ret)
if (!ret) {
bch2_btree_iter_set_pos(iter, next_pos);
atomic_long_inc(&c->extent_migrate_done);
}
err:
if (ret == -EINTR)
ret = 0;
if (ret)
......
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