[f2fs-dev] [PATCH v2 2/2] f2fs: protect sysfs thread priority updates with s_umount

Wenjie Qi <[email protected]> Mon, 3 Aug 2026 17:23:07 +0800
Newsgroups net.sourceforge.lists.linux-f2fs-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
The sysfs store path already takes s_umount for GC thread control
entries, so thread state is not changed while unmount or remount is
tearing the filesystem down.

ckpt_thread_ioprio and critical_task_priority also touch checkpoint or
GC thread scheduling state, but they are not covered by that
serialization. They can race with remount or teardown paths that are
stopping those threads.

Extend the existing s_umount protection to these thread-priority sysfs
entries as well.

Signed-off-by: Wenjie Qi <[email protected]>
---
 fs/f2fs/sysfs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 070f9807ae81..aa1621419932 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -1007,13 +1007,15 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
 	ssize_t ret;
 	bool gc_entry = (!strcmp(a->attr.name, "gc_urgent") ||
 					a->struct_type == GC_THREAD);
+	bool thread_entry = !strcmp(a->attr.name, "ckpt_thread_ioprio") ||
+			!strcmp(a->attr.name, "critical_task_priority");
 
-	if (gc_entry) {
+	if (gc_entry || thread_entry) {
 		if (!down_read_trylock(&sbi->sb->s_umount))
 			return -EAGAIN;
 	}
 	ret = __sbi_store(a, sbi, buf, count);
-	if (gc_entry)
+	if (gc_entry || thread_entry)
 		up_read(&sbi->sb->s_umount);
 
 	return ret;
-- 
2.43.0



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel