bcachefs: Fix an RCU splat
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 15 Apr 2021 22:31:58 +0000 (18:31 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:00 +0000 (17:09 -0400)
Writepoints are never deallocated so the rcu_read_lock() isn't really
needed, but we are doing lockless list traversal.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_foreground.c

index 4834ac798b9e9fc236f69426d4553d15faa1e119..56b114888e49a351d089fbcf178fcff773cd4214 100644 (file)
@@ -683,11 +683,14 @@ static struct write_point *__writepoint_find(struct hlist_head *head,
 {
        struct write_point *wp;
 
+       rcu_read_lock();
        hlist_for_each_entry_rcu(wp, head, node)
                if (wp->write_point == write_point)
-                       return wp;
-
-       return NULL;
+                       goto out;
+       wp = NULL;
+out:
+       rcu_read_unlock();
+       return wp;
 }
 
 static inline bool too_many_writepoints(struct bch_fs *c, unsigned factor)