summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjguzik@gmail.com>2026-06-10 17:39:54 +0300
committerChristian Brauner <brauner@kernel.org>2026-06-12 15:26:27 +0300
commitcf30ceccfaec3d2549ff60f7c915625f12dd3a93 (patch)
tree5213a336e79d81c4f8e24006e5c2a4c1f58c5f43
parent86e9d295084019f4df8ef8e477f39aa42d9a7ef8 (diff)
downloadlinux-cf30ceccfaec3d2549ff60f7c915625f12dd3a93.tar.xz
fs: fix ups and tidy ups to /proc/filesystems caching
- add missing unlocks in some corner cases - whitespace touch ups - s/smp_store_release/rcu_assign_pointer/ [nop, the macro expands to the same thing] - mark file_systems_string as __read_mostly Signed-off-by: Mateusz Guzik <mjguzik@gmail.com> Link: https://patch.msgid.link/20260610143954.34185-1-mjguzik@gmail.com Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
-rw-r--r--fs/filesystems.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/filesystems.c b/fs/filesystems.c
index 771fc31a69b8..673a03b5f32b 100644
--- a/fs/filesystems.c
+++ b/fs/filesystems.c
@@ -54,7 +54,7 @@ struct file_systems_string {
};
static unsigned long file_systems_gen;
-static struct file_systems_string __rcu *file_systems_string;
+static struct file_systems_string __read_mostly __rcu *file_systems_string;
static void invalidate_filesystems_string(void);
#else
@@ -269,7 +269,7 @@ retry:
hlist_for_each_entry_rcu(p, &file_systems, list) {
if (!(p->fs_flags & FS_REQUIRES_DEV))
newlen += strlen("nodev");
- newlen += strlen("\t") + strlen(p->name) + strlen("\n");
+ newlen += strlen("\t") + strlen(p->name) + strlen("\n");
}
spin_unlock(&file_systems_lock);
@@ -289,6 +289,7 @@ retry:
* Did someone beat us to it?
*/
if (old && old->gen == file_systems_gen) {
+ spin_unlock(&file_systems_lock);
kfree(new);
return 0;
}
@@ -297,6 +298,7 @@ retry:
* Did the list change in the meantime?
*/
if (gen != file_systems_gen) {
+ spin_unlock(&file_systems_lock);
kfree(new);
goto retry;
}
@@ -321,15 +323,11 @@ retry:
* generation above and messes it up.
*/
spin_unlock(&file_systems_lock);
- if (old)
- kfree_rcu(old, rcu);
+ kfree(new);
return -EINVAL;
}
- /*
- * Paired with consume fence in READ_ONCE() in filesystems_proc_show()
- */
- smp_store_release(&file_systems_string, new);
+ rcu_assign_pointer(file_systems_string, new);
spin_unlock(&file_systems_lock);
if (old)
kfree_rcu(old, rcu);