aboutsummaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_cache.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-04-08 22:26:53 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:05 -0400
commitc205321b12058afc757a5a41352b5042a27b7223 (patch)
treeca1b72451904eaa1256694f61fdef9aafc179a14 /fs/bcachefs/btree_cache.c
parent4351d3ecb4a2d0c7165b3b72bc4bd1c02371685d (diff)
bcachefs: Drop all btree locks when submitting btree node reads
As a rule we don't want to be holding btree locks while submitting IO - this will improve overall filesystem latency. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_cache.c')
-rw-r--r--fs/bcachefs/btree_cache.c39
1 files changed, 29 insertions, 10 deletions
diff --git a/fs/bcachefs/btree_cache.c b/fs/bcachefs/btree_cache.c
index 5991ebee228c..15f597ab03e7 100644
--- a/fs/bcachefs/btree_cache.c
+++ b/fs/bcachefs/btree_cache.c
@@ -663,13 +663,9 @@ static noinline struct btree *bch2_btree_node_fill(struct bch_fs *c,
return NULL;
}
- /*
- * Unlock before doing IO:
- *
- * XXX: ideally should be dropping all btree node locks here
- */
- if (iter && btree_node_read_locked(iter, level + 1))
- btree_node_unlock(iter, level + 1);
+ /* Unlock before doing IO: */
+ if (iter && sync)
+ bch2_trans_unlock(iter->trans);
bch2_btree_node_read(c, b, sync);
@@ -680,6 +676,16 @@ static noinline struct btree *bch2_btree_node_fill(struct bch_fs *c,
return NULL;
}
+ /*
+ * XXX: this will probably always fail because btree_iter_relock()
+ * currently fails for iterators that aren't pointed at a valid btree
+ * node
+ */
+ if (iter && !bch2_trans_relock(iter->trans)) {
+ six_unlock_intent(&b->c.lock);
+ return ERR_PTR(-EINTR);
+ }
+
if (lock_type == SIX_LOCK_read)
six_lock_downgrade(&b->c.lock);
@@ -824,9 +830,22 @@ lock_node:
}
}
- /* XXX: waiting on IO with btree locks held: */
- wait_on_bit_io(&b->flags, BTREE_NODE_read_in_flight,
- TASK_UNINTERRUPTIBLE);
+ if (unlikely(btree_node_read_in_flight(b))) {
+ six_unlock_type(&b->c.lock, lock_type);
+ bch2_trans_unlock(iter->trans);
+
+ wait_on_bit_io(&b->flags, BTREE_NODE_read_in_flight,
+ TASK_UNINTERRUPTIBLE);
+
+ /*
+ * XXX: check if this always fails - btree_iter_relock()
+ * currently fails for iterators that aren't pointed at a valid
+ * btree node
+ */
+ if (iter && !bch2_trans_relock(iter->trans))
+ return ERR_PTR(-EINTR);
+ goto retry;
+ }
prefetch(b->aux_data);