init: fix init_dup
PATCH 1/1 init: fix init_dup
Don't allocate an unused fd for each call. Also drop the extra reference from filp_open after the init_dup calls while we're at it.
Reported-by Stephen Rothwell <[email protected]>
---
Al, feel free to fold this into the original patch, as that is the last one in the branch.
fs/init.c | 2 +- init/main.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
fs/init.c +1 -1
@@ -260,6 +260,6 @@ int __init init_dup(struct file *file) fd =get_unused_fd_flags (0 );if (fd <0 )return fd; -fd_install (get_unused_fd_flags (0 ),get_file (file)); +fd_install (fd,get_file (file));return 0 ; }
init/main.c +1 -0
@@ -1470,6 +1470,7 @@ void __init console_on_rootfs(void)init_dup (file);init_dup (file);init_dup (file); +fput (file); } static noinline void __init kernel_init_freeable(void)
Signature · 1 line
2.27.0
Hi Christoph,
Quoted 43 lines · On Mon, 3 Aug 2020 15:58:19 +0200 Christoph Hellwig <[email protected]> wrote:
Don't allocate an unused fd for each call. Also drop the extra reference from
filp_openafter theinit_dupcalls while we're at it.Fixes 36e96b411649 ("init: add an init_dup helper")Reported-by Stephen Rothwell <[email protected]>
Signed-off-by Christoph Hellwig <[email protected]>---
Al, feel free to fold this into the original patch, as that is the last one in the branch.
fs/init.c | 2 +- init/main.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)fs/init.c +1
-1@@ -260,6 +260,6 @@ int __init init_dup(struct file *file) fd =get_unused_fd_flags (0 );if (fd <0 )return fd; -fd_install (get_unused_fd_flags (0 ),get_file (file)); +fd_install (fd,get_file (file));return 0 ; }init/main.c +1
-0@@ -1470,6 +1470,7 @@ void __init console_on_rootfs(void)init_dup (file);init_dup (file);init_dup (file); +fput (file); } static noinline void __init kernel_init_freeable(void)Signature · 1 line
2.27.0
Thanks, I have added that to the vfs tree merge today.
Signature · 2 lines
Cheers, Stephen Rothwell
Hi Christoph,
Quoted 41 lines · On Tue, 4 Aug 2020 09:53:54 +1000 Stephen Rothwell <[email protected]> wrote:
Quoted 39 lines · On Mon, 3 Aug 2020 15:58:19 +0200 Christoph Hellwig <[email protected]> wrote:
Don't allocate an unused fd for each call. Also drop the extra reference from
filp_openafter theinit_dupcalls while we're at it.Fixes 36e96b411649 ("init: add an init_dup helper")Reported-by Stephen Rothwell <[email protected]>
Signed-off-by Christoph Hellwig <[email protected]>---
Al, feel free to fold this into the original patch, as that is the last one in the branch.
fs/init.c | 2 +- init/main.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)fs/init.c +1
-1@@ -260,6 +260,6 @@ int __init init_dup(struct file *file) fd =get_unused_fd_flags (0 );if (fd <0 )return fd; -fd_install (get_unused_fd_flags (0 ),get_file (file)); +fd_install (fd,get_file (file));return 0 ; }init/main.c +1
-0@@ -1470,6 +1470,7 @@ void __init console_on_rootfs(void)init_dup (file);init_dup (file);init_dup (file); +fput (file); }
Quoted 6 lines
Quoted 4 lines
init/main.c +0
-0static noinline void __init kernel_init_freeable(void)Signature · 1 line
2.27.0Thanks, I have added that to the vfs tree merge today.
This fixes my qemu problems, thanks.
Signature · 2 lines
Cheers, Stephen Rothwell
Al Viro
maintainerQuoted 10 lines · Christoph Hellwig
Don't allocate an unused fd for each call. Also drop the extra reference from
filp_openafter theinit_dupcalls while we're at it.Fixes 36e96b411649 ("init: add an init_dup helper")Reported-by Stephen Rothwell <[email protected]>
Signed-off-by Christoph Hellwig <[email protected]>---
Al, feel free to fold this into the original patch, as that is the last one in the branch.
Done and pushed, along with regenerated #for-next