linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] init: fix init_dup
@ 2020-08-03 13:58 Christoph Hellwig
  2020-08-03 23:53 ` Stephen Rothwell
  2020-08-04  1:21 ` Al Viro
  0 siblings, 2 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-08-03 13:58 UTC (permalink / raw)
  To: viro; +Cc: sfr, linux-fsdevel

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.

Fixes: 36e96b411649 ("init: add an init_dup helper")
Reported-by Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---

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(-)

diff --git a/fs/init.c b/fs/init.c
index 730e05acda2392..e9c320a48cf157 100644
--- a/fs/init.c
+++ b/fs/init.c
@@ -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;
 }
diff --git a/init/main.c b/init/main.c
index 089e21504b1fc1..9dae9c4f806bb9 100644
--- a/init/main.c
+++ b/init/main.c
@@ -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)
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] init: fix init_dup
  2020-08-03 13:58 [PATCH] init: fix init_dup Christoph Hellwig
@ 2020-08-03 23:53 ` Stephen Rothwell
  2020-08-04  8:39   ` Stephen Rothwell
  2020-08-04  1:21 ` Al Viro
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Rothwell @ 2020-08-03 23:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: viro, linux-fsdevel

[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]

Hi Christoph,

On Mon,  3 Aug 2020 15:58:19 +0200 Christoph Hellwig <hch@lst.de> wrote:
>
> 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.
> 
> Fixes: 36e96b411649 ("init: add an init_dup helper")
> Reported-by Stephen Rothwell <sfr@canb.auug.org.au>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> 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(-)
> 
> diff --git a/fs/init.c b/fs/init.c
> index 730e05acda2392..e9c320a48cf157 100644
> --- a/fs/init.c
> +++ b/fs/init.c
> @@ -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;
>  }
> diff --git a/init/main.c b/init/main.c
> index 089e21504b1fc1..9dae9c4f806bb9 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -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)
> -- 
> 2.27.0
> 

Thanks, I have added that to the vfs tree merge today.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] init: fix init_dup
  2020-08-03 13:58 [PATCH] init: fix init_dup Christoph Hellwig
  2020-08-03 23:53 ` Stephen Rothwell
@ 2020-08-04  1:21 ` Al Viro
  1 sibling, 0 replies; 4+ messages in thread
From: Al Viro @ 2020-08-04  1:21 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: sfr, linux-fsdevel

On Mon, Aug 03, 2020 at 03:58:19PM +0200, Christoph Hellwig wrote:
> 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.
> 
> Fixes: 36e96b411649 ("init: add an init_dup helper")
> Reported-by Stephen Rothwell <sfr@canb.auug.org.au>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> 
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] init: fix init_dup
  2020-08-03 23:53 ` Stephen Rothwell
@ 2020-08-04  8:39   ` Stephen Rothwell
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Rothwell @ 2020-08-04  8:39 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: viro, linux-fsdevel

[-- Attachment #1: Type: text/plain, Size: 1652 bytes --]

Hi Christoph,

On Tue, 4 Aug 2020 09:53:54 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> On Mon,  3 Aug 2020 15:58:19 +0200 Christoph Hellwig <hch@lst.de> wrote:
> >
> > 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.
> > 
> > Fixes: 36e96b411649 ("init: add an init_dup helper")
> > Reported-by Stephen Rothwell <sfr@canb.auug.org.au>
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> > 
> > 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(-)
> > 
> > diff --git a/fs/init.c b/fs/init.c
> > index 730e05acda2392..e9c320a48cf157 100644
> > --- a/fs/init.c
> > +++ b/fs/init.c
> > @@ -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;
> >  }
> > diff --git a/init/main.c b/init/main.c
> > index 089e21504b1fc1..9dae9c4f806bb9 100644
> > --- a/init/main.c
> > +++ b/init/main.c
> > @@ -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)
> > -- 
> > 2.27.0
> >   
> 
> Thanks, I have added that to the vfs tree merge today.

This fixes my qemu problems, thanks.

-- 
Cheers,
Stephen Rothwell

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-04  8:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-03 13:58 [PATCH] init: fix init_dup Christoph Hellwig
2020-08-03 23:53 ` Stephen Rothwell
2020-08-04  8:39   ` Stephen Rothwell
2020-08-04  1:21 ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).