diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-08-30 01:34:37 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:09:11 +0200 |
commit | 5f8077cca89bdcc3d7660567462b17831356826d (patch) | |
tree | 20291e4a1674b0a38be2ff525bc66f16f4389597 /fs/bcachefs | |
parent | bcachefs: Refactor bch2_trans_update_extent() (diff) | |
download | linux-5f8077cca89bdcc3d7660567462b17831356826d.tar.xz linux-5f8077cca89bdcc3d7660567462b17831356826d.zip |
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: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to '')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 4 | ||||
-rw-r--r-- | fs/bcachefs/btree_types.h | 10 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 9 | ||||
-rw-r--r-- | fs/bcachefs/ec.c | 5 | ||||
-rw-r--r-- | fs/bcachefs/io.c | 5 | ||||
-rw-r--r-- | fs/bcachefs/move.c | 9 |
6 files changed, 22 insertions, 20 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index ef5e7e9884f5..70995d61dd49 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -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 diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h index 6ef3285541f2..577cc57174fa 100644 --- a/fs/bcachefs/btree_types.h +++ b/fs/bcachefs/btree_types.h @@ -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; diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 1b4945145428..2409696dc63f 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -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 @@ retry: 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| diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c index c20c80bd344d..7ad74987757f 100644 --- a/fs/bcachefs/ec.c +++ b/fs/bcachefs/ec.c @@ -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) diff --git a/fs/bcachefs/io.c b/fs/bcachefs/io.c index 27f6b3245741..34295419190d 100644 --- a/fs/bcachefs/io.c +++ b/fs/bcachefs/io.c @@ -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; diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index 8d28d8fc5395..c804af8b81de 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -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) |