diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-05-10 17:15:30 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:22 -0400 |
commit | 60755344c6b18753c93b353f147c2e23b8b18de1 (patch) | |
tree | 535c5bb515ce407ff78b9822199c671e1757f430 /fs | |
parent | b03b81dfd268938c6ed3b0ec79b4983523efb303 (diff) | |
download | linux-stable-60755344c6b18753c93b353f147c2e23b8b18de1.tar.gz linux-stable-60755344c6b18753c93b353f147c2e23b8b18de1.tar.bz2 linux-stable-60755344c6b18753c93b353f147c2e23b8b18de1.zip |
bcachefs: kill BTREE_ITER_NOUNLOCK
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/btree_cache.c | 3 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.c | 7 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.h | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_locking.h | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_types.h | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 21 |
6 files changed, 11 insertions, 26 deletions
diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c index 422186e67f3f..ece2c4d2ebd8 100644 --- a/fs/bcachefs/btree_cache.c +++ b/fs/bcachefs/btree_cache.c @@ -806,8 +806,7 @@ struct btree *bch2_btree_node_get_sibling(struct bch_fs *c, ret = bch2_btree_node_get(c, iter, &tmp.k, level, SIX_LOCK_intent); - if (PTR_ERR_OR_ZERO(ret) == -EINTR && - !(iter->flags & BTREE_ITER_NOUNLOCK)) { + if (PTR_ERR_OR_ZERO(ret) == -EINTR && !trans->nounlock) { struct btree_iter *linked; if (!bch2_btree_node_relock(iter, level + 1)) diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index f6c2be149645..e18a88cd972e 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -224,7 +224,7 @@ bool __bch2_btree_node_lock(struct btree *b, struct bpos pos, */ if (type == SIX_LOCK_intent && linked->nodes_locked != linked->nodes_intent_locked) { - if (!(iter->flags & BTREE_ITER_NOUNLOCK)) { + if (!(iter->trans->nounlock)) { linked->locks_want = max_t(unsigned, linked->locks_want, __fls(linked->nodes_locked) + 1); @@ -240,7 +240,7 @@ bool __bch2_btree_node_lock(struct btree *b, struct bpos pos, */ if (linked->btree_id == iter->btree_id && level > __fls(linked->nodes_locked)) { - if (!(iter->flags & BTREE_ITER_NOUNLOCK)) { + if (!(iter->trans->nounlock)) { linked->locks_want = max(level + 1, max_t(unsigned, linked->locks_want, @@ -269,9 +269,6 @@ void bch2_btree_iter_verify_locks(struct btree_iter *iter) { unsigned l; - BUG_ON((iter->flags & BTREE_ITER_NOUNLOCK) && - !btree_node_locked(iter, 0)); - for (l = 0; btree_iter_node(iter, l); l++) { if (iter->uptodate >= BTREE_ITER_NEED_RELOCK && !btree_node_locked(iter, l)) diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index b2c0b6816d1c..ee5437813604 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -117,7 +117,7 @@ static inline bool bch2_btree_iter_upgrade(struct btree_iter *iter, new_locks_want = min(new_locks_want, BTREE_MAX_DEPTH); return iter->locks_want < new_locks_want - ? (!(iter->flags & BTREE_ITER_NOUNLOCK) + ? (!iter->trans->nounlock ? __bch2_btree_iter_upgrade(iter, new_locks_want) : __bch2_btree_iter_upgrade_nounlock(iter, new_locks_want)) : iter->uptodate <= BTREE_ITER_NEED_PEEK; diff --git a/fs/bcachefs/btree_locking.h b/fs/bcachefs/btree_locking.h index 33bc94a714c6..6591da0a52b3 100644 --- a/fs/bcachefs/btree_locking.h +++ b/fs/bcachefs/btree_locking.h @@ -107,7 +107,7 @@ static inline void __btree_node_unlock(struct btree_iter *iter, unsigned level) static inline void btree_node_unlock(struct btree_iter *iter, unsigned level) { - BUG_ON(!level && iter->flags & BTREE_ITER_NOUNLOCK); + EBUG_ON(!level && iter->trans->nounlock); __btree_node_unlock(iter, level); } diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h index ece4f30b3f85..d88f1c911d04 100644 --- a/fs/bcachefs/btree_types.h +++ b/fs/bcachefs/btree_types.h @@ -197,7 +197,6 @@ enum btree_iter_type { */ #define BTREE_ITER_IS_EXTENTS (1 << 4) #define BTREE_ITER_ERROR (1 << 5) -#define BTREE_ITER_NOUNLOCK (1 << 6) enum btree_iter_uptodate { BTREE_ITER_UPTODATE = 0, @@ -287,6 +286,7 @@ struct btree_trans { u8 size; unsigned used_mempool:1; unsigned error:1; + unsigned nounlock:1; unsigned mem_top; unsigned mem_bytes; diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index a449f983a343..b5749b19c3b9 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -551,7 +551,6 @@ static inline int do_btree_insert_at(struct btree_trans *trans, struct bch_fs *c = trans->c; struct bch_fs_usage_online *fs_usage = NULL; struct btree_insert_entry *i; - struct btree_iter *linked; int ret; if (likely(!(trans->flags & BTREE_INSERT_NO_CLEAR_REPLICAS))) { @@ -624,17 +623,6 @@ static inline int do_btree_insert_at(struct btree_trans *trans, i->k->k.version = MAX_VERSION; } - if (trans->flags & BTREE_INSERT_NOUNLOCK) { - /* - * linked iterators that weren't being updated may or may not - * have been traversed/locked, depending on what the caller was - * doing: - */ - trans_for_each_iter(trans, linked) - if (linked->uptodate < BTREE_ITER_NEED_RELOCK) - linked->flags |= BTREE_ITER_NOUNLOCK; - } - trans_for_each_update_iter(trans, i) if (update_has_triggers(trans, i) && !update_triggers_transactional(trans, i)) @@ -809,7 +797,6 @@ static int __bch2_trans_commit(struct btree_trans *trans, { struct bch_fs *c = trans->c; struct btree_insert_entry *i; - struct btree_iter *linked; int ret; trans_for_each_update_iter(trans, i) { @@ -832,18 +819,20 @@ static int __bch2_trans_commit(struct btree_trans *trans, if (unlikely(ret)) goto err; + if (trans->flags & BTREE_INSERT_NOUNLOCK) + trans->nounlock = true; + trans_for_each_update_leaf(trans, i) bch2_foreground_maybe_merge(c, i->iter, 0, trans->flags); + trans->nounlock = false; + trans_for_each_update_iter(trans, i) bch2_btree_iter_downgrade(i->iter); err: /* make sure we didn't drop or screw up locks: */ bch2_btree_trans_verify_locks(trans); - trans_for_each_iter(trans, linked) - linked->flags &= ~BTREE_ITER_NOUNLOCK; - return ret; } |