summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bcachefs_revision2
-rw-r--r--libbcachefs/btree_gc.c5
-rw-r--r--libbcachefs/btree_iter.c2
-rw-r--r--libbcachefs/btree_update_interior.c15
-rw-r--r--libbcachefs/recovery.c2
5 files changed, 20 insertions, 6 deletions
diff --git a/.bcachefs_revision b/.bcachefs_revision
index 695629a4..c99a414a 100644
--- a/.bcachefs_revision
+++ b/.bcachefs_revision
@@ -1 +1 @@
-7e03c1ab0ef2e3148ba70656eab67471c85a0419
+d0625a441839f54b9600783c3a6b90db6f197cad
diff --git a/libbcachefs/btree_gc.c b/libbcachefs/btree_gc.c
index 8b114d4f..c4c2e1a3 100644
--- a/libbcachefs/btree_gc.c
+++ b/libbcachefs/btree_gc.c
@@ -1040,11 +1040,12 @@ next:
old_nodes[i] = new_nodes[i];
} else {
old_nodes[i] = NULL;
- if (new_nodes[i])
- six_unlock_intent(&new_nodes[i]->lock);
}
}
+ for (i = 0; i < nr_new_nodes; i++)
+ six_unlock_intent(&new_nodes[i]->lock);
+
bch2_btree_update_done(as);
bch2_keylist_free(&keylist, NULL);
}
diff --git a/libbcachefs/btree_iter.c b/libbcachefs/btree_iter.c
index e7f7820f..d1ea9b13 100644
--- a/libbcachefs/btree_iter.c
+++ b/libbcachefs/btree_iter.c
@@ -833,8 +833,6 @@ void bch2_btree_iter_node_replace(struct btree_iter *iter, struct btree *b)
btree_iter_node_set(linked, b);
}
-
- six_unlock_intent(&b->lock);
}
void bch2_btree_iter_node_drop(struct btree_iter *iter, struct btree *b)
diff --git a/libbcachefs/btree_update_interior.c b/libbcachefs/btree_update_interior.c
index 6813eddd..ec0de33f 100644
--- a/libbcachefs/btree_update_interior.c
+++ b/libbcachefs/btree_update_interior.c
@@ -1446,8 +1446,20 @@ static void btree_split(struct btree_update *as, struct btree *b,
bch2_btree_iter_node_replace(iter, n2);
bch2_btree_iter_node_replace(iter, n1);
+ /*
+ * The old node must be freed (in memory) _before_ unlocking the new
+ * nodes - else another thread could re-acquire a read lock on the old
+ * node after another thread has locked and updated the new node, thus
+ * seeing stale data:
+ */
bch2_btree_node_free_inmem(c, b, iter);
+ if (n3)
+ six_unlock_intent(&n3->lock);
+ if (n2)
+ six_unlock_intent(&n2->lock);
+ six_unlock_intent(&n1->lock);
+
bch2_btree_trans_verify_locks(iter->trans);
bch2_time_stats_update(&c->times[BCH_TIME_btree_node_split],
@@ -1761,6 +1773,8 @@ retry:
bch2_btree_node_free_inmem(c, b, iter);
bch2_btree_node_free_inmem(c, m, iter);
+ six_unlock_intent(&n->lock);
+
bch2_btree_update_done(as);
if (!(flags & BTREE_INSERT_GC_LOCK_HELD))
@@ -1855,6 +1869,7 @@ static int __btree_node_rewrite(struct bch_fs *c, struct btree_iter *iter,
bch2_btree_iter_node_drop(iter, b);
bch2_btree_iter_node_replace(iter, n);
bch2_btree_node_free_inmem(c, b, iter);
+ six_unlock_intent(&n->lock);
bch2_btree_update_done(as);
return 0;
diff --git a/libbcachefs/recovery.c b/libbcachefs/recovery.c
index 095eef38..23f3ed54 100644
--- a/libbcachefs/recovery.c
+++ b/libbcachefs/recovery.c
@@ -1011,7 +1011,7 @@ int bch2_fs_initialize(struct bch_fs *c)
bch2_create_trans(&trans, BCACHEFS_ROOT_INO,
&root_inode, &lostfound_inode,
&lostfound,
- 0, 0, 0755, 0,
+ 0, 0, S_IFDIR|0755, 0,
NULL, NULL));
if (ret)
goto err;