bcachefs: Fix a pcpu var splat
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 7 Oct 2021 22:18:01 +0000 (18:18 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:13 +0000 (17:09 -0400)
this_cpu_ptr() emits a warning when used without preemption disabled -
harmless in this case, as we have other locking where
bch2_acc_percpu_u64s() is used.

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

index f287bca8498dce507b14cb0825d3d31fd4215d34..8211c9a1b6cb761120d5d42e58108a43ad53c260 100644 (file)
@@ -893,9 +893,14 @@ void eytzinger0_find_test(void)
  */
 u64 *bch2_acc_percpu_u64s(u64 __percpu *p, unsigned nr)
 {
-       u64 *ret = this_cpu_ptr(p);
+       u64 *ret;
        int cpu;
 
+       /* access to pcpu vars has to be blocked by other locking */
+       preempt_disable();
+       ret = this_cpu_ptr(p);
+       preempt_enable();
+
        for_each_possible_cpu(cpu) {
                u64 *i = per_cpu_ptr(p, cpu);