Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

init: flush async file closing

When unpacking the initramfs or when mounting block devices we need to
ensure that any delayed fput() finished to prevent spurious errors.
The init process can be a proper kernel thread or a user mode helper.
In the latter case PF_KTHREAD isn't set. So we need to do both
flush_delayed_work() and task_work_run().

Since we'll port block device opening and closing to regular file open
and closing we need to ensure the same as for the initramfs. So just
make that a little helper.

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Tested-by: Srikanth Aithal <sraithal@amd.com>
Link: https://lore.kernel.org/r/CA+G9fYttTwsbFuVq10igbSvP5xC6bf_XijM=mpUqrJV=uvUirQ@mail.gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>

+15 -3
+3
init/do_mounts.c
··· 208 208 goto out; 209 209 case -EACCES: 210 210 case -EINVAL: 211 + #ifdef CONFIG_BLOCK 212 + init_flush_fput(); 213 + #endif 211 214 continue; 212 215 } 213 216 /*
+9
init/do_mounts.h
··· 9 9 #include <linux/major.h> 10 10 #include <linux/root_dev.h> 11 11 #include <linux/init_syscalls.h> 12 + #include <linux/task_work.h> 13 + #include <linux/file.h> 12 14 13 15 void mount_root_generic(char *name, char *pretty_name, int flags); 14 16 void mount_root(char *root_device_name); ··· 43 41 } 44 42 45 43 #endif 44 + 45 + /* Ensure that async file closing finished to prevent spurious errors. */ 46 + static inline void init_flush_fput(void) 47 + { 48 + flush_delayed_fput(); 49 + task_work_run(); 50 + }
+3 -3
init/initramfs.c
··· 16 16 #include <linux/mm.h> 17 17 #include <linux/namei.h> 18 18 #include <linux/init_syscalls.h> 19 - #include <linux/task_work.h> 20 19 #include <linux/umh.h> 20 + 21 + #include "do_mounts.h" 21 22 22 23 static __initdata bool csum_present; 23 24 static __initdata u32 io_csum; ··· 737 736 initrd_start = 0; 738 737 initrd_end = 0; 739 738 740 - flush_delayed_fput(); 741 - task_work_run(); 739 + init_flush_fput(); 742 740 } 743 741 744 742 static ASYNC_DOMAIN_EXCLUSIVE(initramfs_domain);