proc: show mnt_id in fdinfo files
PATCH 1/1 proc: show mnt_id in fdinfo files
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.
--- fs/proc/fd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/proc/fd.c +4 -2
@@ -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);
Signature · 1 line
1.8.5.3
Quoted 7 lines · Andrey Vagin
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.
Quoted 6 lines
Cc Al Viro <[email protected]>Cc Oleg Nesterov <[email protected]>Cc Andrew Morton <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Signed-off-by Andrey Vagin <[email protected]>
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.
Quoted 29 lines
--- fs/proc/fd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)fs/proc/fd.c +4
-2@@ -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);
Cyrill Gorcunov
Reviewed-byQuoted 15 lines · Pavel Emelyanov
Quoted 7 lines · Andrey Vagin
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.
Quoted 6 lines
Cc Al Viro <[email protected]>Cc Oleg Nesterov <[email protected]>Cc Andrew Morton <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Signed-off-by Andrey Vagin <[email protected]>
Quoted 5 lines
These IDs are already shown in the
/proc/$pid/mountinfo, and for some FSs can be obtained viapath_to_handle_at(), so this patch just makes it work for any FS and speeds things up.Acked-by Pavel Emelyanov <[email protected]>
I think Documentation/filesystems/proc.txt should be updated on top. Other than that
Quoted 16 lines · On Mon, 17 Mar 2014 15:50:13 +0400 Cyrill Gorcunov <[email protected]> wrote:
Quoted 15 lines · Pavel Emelyanov
Quoted 13 lines · Andrey Vagin
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 <[email protected]>Cc Oleg Nesterov <[email protected]>Cc Andrew Morton <[email protected]>Cc Cyrill Gorcunov <[email protected]>Cc Pavel Emelyanov <[email protected]>Signed-off-by Andrey Vagin <[email protected]>
Quoted 7 lines
Quoted 5 lines
These IDs are already shown in the
/proc/$pid/mountinfo, and for some FSs can be obtained viapath_to_handle_at(), so this patch just makes it work for any FS and speeds things up.Acked-by Pavel Emelyanov <[email protected]>I think
Documentation/filesystems/proc.txtshould be updated on top.
Yes please.
It would be nice to see example output in the changelog as well please.