linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] proc: show mnt_id in fdinfo files
@ 2014-03-17 10:39 Andrey Vagin
  2014-03-17 11:30 ` Pavel Emelyanov
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Vagin @ 2014-03-17 10:39 UTC (permalink / raw)
  To: linux-kernel
  Cc: criu, Andrey Vagin, Al Viro, Oleg Nesterov, Andrew Morton,
	Cyrill Gorcunov, Pavel Emelyanov

Currently we don't have a way how to determing from which mount point
file has been opened. This information is required for proper dumping
and restoring file descriptos due to presence of mount namespaces. It's
possible, that two file descriptors are opened using the same paths, but
one fd references mount point from one namespace while the other fd --
from other namespace.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
---
 fs/proc/fd.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 985ea88..0788d09 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -11,6 +11,7 @@
 
 #include <linux/proc_fs.h>
 
+#include "../mount.h"
 #include "internal.h"
 #include "fd.h"
 
@@ -48,8 +49,9 @@ static int seq_show(struct seq_file *m, void *v)
 	}
 
 	if (!ret) {
-                seq_printf(m, "pos:\t%lli\nflags:\t0%o\n",
-			   (long long)file->f_pos, f_flags);
+		seq_printf(m, "pos:\t%lli\nflags:\t0%o\nmnt_id:\t%i\n",
+			   (long long)file->f_pos, f_flags,
+			   real_mount(file->f_path.mnt)->mnt_id);
 		if (file->f_op->show_fdinfo)
 			ret = file->f_op->show_fdinfo(m, file);
 		fput(file);
-- 
1.8.5.3


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

* Re: [PATCH] proc: show mnt_id in fdinfo files
  2014-03-17 10:39 [PATCH] proc: show mnt_id in fdinfo files Andrey Vagin
@ 2014-03-17 11:30 ` Pavel Emelyanov
  2014-03-17 11:50   ` Cyrill Gorcunov
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Emelyanov @ 2014-03-17 11:30 UTC (permalink / raw)
  To: Andrey Vagin
  Cc: linux-kernel, criu, Al Viro, Oleg Nesterov, Andrew Morton,
	Cyrill Gorcunov

On 03/17/2014 02:39 PM, Andrey Vagin wrote:
> Currently we don't have a way how to determing from which mount point
> file has been opened. This information is required for proper dumping
> and restoring file descriptos due to presence of mount namespaces. It's
> possible, that two file descriptors are opened using the same paths, but
> one fd references mount point from one namespace while the other fd --
> from other namespace.
> 
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Cyrill Gorcunov <gorcunov@openvz.org>
> Cc: Pavel Emelyanov <xemul@parallels.com>
> Signed-off-by: Andrey Vagin <avagin@openvz.org>

These IDs are already shown in the /proc/$pid/mountinfo, and for some FSs
can be obtained via path_to_handle_at(), so this patch just makes it work
for any FS and speeds things up.

Acked-by: Pavel Emelyanov <xemul@parallels.com>

> ---
>  fs/proc/fd.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/proc/fd.c b/fs/proc/fd.c
> index 985ea88..0788d09 100644
> --- a/fs/proc/fd.c
> +++ b/fs/proc/fd.c
> @@ -11,6 +11,7 @@
>  
>  #include <linux/proc_fs.h>
>  
> +#include "../mount.h"
>  #include "internal.h"
>  #include "fd.h"
>  
> @@ -48,8 +49,9 @@ static int seq_show(struct seq_file *m, void *v)
>  	}
>  
>  	if (!ret) {
> -                seq_printf(m, "pos:\t%lli\nflags:\t0%o\n",
> -			   (long long)file->f_pos, f_flags);
> +		seq_printf(m, "pos:\t%lli\nflags:\t0%o\nmnt_id:\t%i\n",
> +			   (long long)file->f_pos, f_flags,
> +			   real_mount(file->f_path.mnt)->mnt_id);
>  		if (file->f_op->show_fdinfo)
>  			ret = file->f_op->show_fdinfo(m, file);
>  		fput(file);
> 



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

* Re: [PATCH] proc: show mnt_id in fdinfo files
  2014-03-17 11:30 ` Pavel Emelyanov
@ 2014-03-17 11:50   ` Cyrill Gorcunov
  2014-03-19 23:22     ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Cyrill Gorcunov @ 2014-03-17 11:50 UTC (permalink / raw)
  To: Pavel Emelyanov
  Cc: Andrey Vagin, linux-kernel, criu, Al Viro, Oleg Nesterov, Andrew Morton

On Mon, Mar 17, 2014 at 03:30:26PM +0400, Pavel Emelyanov wrote:
> On 03/17/2014 02:39 PM, Andrey Vagin wrote:
> > Currently we don't have a way how to determing from which mount point
> > file has been opened. This information is required for proper dumping
> > and restoring file descriptos due to presence of mount namespaces. It's
> > possible, that two file descriptors are opened using the same paths, but
> > one fd references mount point from one namespace while the other fd --
> > from other namespace.
> > 
> > Cc: Al Viro <viro@zeniv.linux.org.uk>
> > Cc: Oleg Nesterov <oleg@redhat.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Cyrill Gorcunov <gorcunov@openvz.org>
> > Cc: Pavel Emelyanov <xemul@parallels.com>
> > Signed-off-by: Andrey Vagin <avagin@openvz.org>
> 
> These IDs are already shown in the /proc/$pid/mountinfo, and for some FSs
> can be obtained via path_to_handle_at(), so this patch just makes it work
> for any FS and speeds things up.
> 
> Acked-by: Pavel Emelyanov <xemul@parallels.com>

I think Documentation/filesystems/proc.txt should be updated on top.
Other than that

Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>

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

* Re: [PATCH] proc: show mnt_id in fdinfo files
  2014-03-17 11:50   ` Cyrill Gorcunov
@ 2014-03-19 23:22     ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2014-03-19 23:22 UTC (permalink / raw)
  To: Cyrill Gorcunov
  Cc: Pavel Emelyanov, Andrey Vagin, linux-kernel, criu, Al Viro,
	Oleg Nesterov

On Mon, 17 Mar 2014 15:50:13 +0400 Cyrill Gorcunov <gorcunov@gmail.com> wrote:

> On Mon, Mar 17, 2014 at 03:30:26PM +0400, Pavel Emelyanov wrote:
> > On 03/17/2014 02:39 PM, Andrey Vagin wrote:
> > > Currently we don't have a way how to determing from which mount point
> > > file has been opened. This information is required for proper dumping
> > > and restoring file descriptos due to presence of mount namespaces. It's
> > > possible, that two file descriptors are opened using the same paths, but
> > > one fd references mount point from one namespace while the other fd --
> > > from other namespace.
> > > 
> > > Cc: Al Viro <viro@zeniv.linux.org.uk>
> > > Cc: Oleg Nesterov <oleg@redhat.com>
> > > Cc: Andrew Morton <akpm@linux-foundation.org>
> > > Cc: Cyrill Gorcunov <gorcunov@openvz.org>
> > > Cc: Pavel Emelyanov <xemul@parallels.com>
> > > Signed-off-by: Andrey Vagin <avagin@openvz.org>
> > 
> > These IDs are already shown in the /proc/$pid/mountinfo, and for some FSs
> > can be obtained via path_to_handle_at(), so this patch just makes it work
> > for any FS and speeds things up.
> > 
> > Acked-by: Pavel Emelyanov <xemul@parallels.com>
> 
> I think Documentation/filesystems/proc.txt should be updated on top.

Yes please.

It would be nice to see example output in the changelog as well please.

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

end of thread, other threads:[~2014-03-19 23:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-17 10:39 [PATCH] proc: show mnt_id in fdinfo files Andrey Vagin
2014-03-17 11:30 ` Pavel Emelyanov
2014-03-17 11:50   ` Cyrill Gorcunov
2014-03-19 23:22     ` Andrew Morton

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