six locks: Disable percpu read lock mode in userspace
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 10 Jun 2023 14:57:23 +0000 (10:57 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:02 +0000 (17:10 -0400)
When running in userspace, we currently don't have a real percpu
implementation available - at least in bcachefs-tools, which is where
this code is currently used in userspace.

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

index 00580f8ff1c5cd59ce7c72fb729b907d55aa281b..7ce45aeaee8d9565aa41c678244d3c1700c2f84b 100644 (file)
@@ -870,6 +870,11 @@ void __six_lock_init(struct six_lock *lock, const char *name,
        lockdep_init_map(&lock->dep_map, name, key, 0);
 #endif
 
+       /*
+        * Don't assume that we have real percpu variables available in
+        * userspace:
+        */
+#ifdef __KERNEL__
        if (flags & SIX_LOCK_INIT_PCPU) {
                /*
                 * We don't return an error here on memory allocation failure
@@ -880,5 +885,6 @@ void __six_lock_init(struct six_lock *lock, const char *name,
                 */
                lock->readers = alloc_percpu(unsigned);
        }
+#endif
 }
 EXPORT_SYMBOL_GPL(__six_lock_init);