summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_update_interior.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-09-10 23:33:08 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:05 -0400
commitee7570546e89ece9b56eaa22c94a6ec0941ec827 (patch)
tree7e454dc52b3f955a76cf46e849ee010ee7dafa24 /fs/bcachefs/btree_update_interior.h
parent9f2772c45460e420de9a88980129bef135c6b76f (diff)
downloadlinux-stable-ee7570546e89ece9b56eaa22c94a6ec0941ec827.tar.gz
linux-stable-ee7570546e89ece9b56eaa22c94a6ec0941ec827.tar.bz2
linux-stable-ee7570546e89ece9b56eaa22c94a6ec0941ec827.zip
bcachefs: Fix a deadlock
Waiting on a btree node write with btree locks held can deadlock, if the write errors: the write error path has to do do a btree update to drop the pointer to the replica that errored. The interior update path has to wait on in flight btree writes before freeing nodes on disk. Previously, this was done in bch2_btree_interior_update_will_free_node(), and could deadlock; now, we just stash a pointer to the node and do it in btree_update_nodes_written(), just prior to the transactional part of the update. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_update_interior.h')
-rw-r--r--fs/bcachefs/btree_update_interior.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_update_interior.h b/fs/bcachefs/btree_update_interior.h
index 7eef3dbb6ef1..7ed67b47e1b9 100644
--- a/fs/bcachefs/btree_update_interior.h
+++ b/fs/bcachefs/btree_update_interior.h
@@ -92,6 +92,10 @@ struct btree_update {
struct btree *new_nodes[BTREE_UPDATE_NODES_MAX];
unsigned nr_new_nodes;
+ struct btree *old_nodes[BTREE_UPDATE_NODES_MAX];
+ __le64 old_nodes_seq[BTREE_UPDATE_NODES_MAX];
+ unsigned nr_old_nodes;
+
open_bucket_idx_t open_buckets[BTREE_UPDATE_NODES_MAX *
BCH_REPLICAS_MAX];
open_bucket_idx_t nr_open_buckets;