summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_update_leaf.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-11-17 16:03:15 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:46 -0400
commit42af0ad569edbfcd252e9abf0badd97b895c34be (patch)
treeae24fa72c52e7f8ed6797a98cae59fdae556f543 /fs/bcachefs/btree_update_leaf.c
parent7fec8266af12b655e98978050e716e12e8544fe6 (diff)
downloadlwn-42af0ad569edbfcd252e9abf0badd97b895c34be.tar.gz
lwn-42af0ad569edbfcd252e9abf0badd97b895c34be.zip
bcachefs: Fix a race with b->write_type
b->write_type needs to be set atomically with setting the btree_node_need_write flag, so move it into b->flags. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_update_leaf.c')
-rw-r--r--fs/bcachefs/btree_update_leaf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index 1405ad4eda02..445f8f57ef0c 100644
--- a/fs/bcachefs/btree_update_leaf.c
+++ b/fs/bcachefs/btree_update_leaf.c
@@ -178,11 +178,11 @@ static int __btree_node_flush(struct journal *j, struct journal_entry_pin *pin,
w->journal.seq != seq)
break;
+ new &= ~BTREE_WRITE_TYPE_MASK;
+ new |= BTREE_WRITE_journal_reclaim;
new |= 1 << BTREE_NODE_need_write;
} while ((v = cmpxchg(&b->flags, old, new)) != old);
- b->write_type = BTREE_WRITE_journal_reclaim;
-
btree_node_write_if_need(c, b, SIX_LOCK_read);
six_unlock_read(&b->c.lock);