From: ebiederm@xmission.com (Eric W. Biederman)
To: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: linux-kernel@vger.kernel.org,
Pavel Emelyanov <xemul@parallels.com>,
Glauber Costa <glommer@parallels.com>,
Andi Kleen <andi@firstfloor.org>, Tejun Heo <tj@kernel.org>,
Matt Helsley <matthltc@us.ibm.com>,
Pekka Enberg <penberg@kernel.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
Vasiliy Kulikov <segoon@openwall.com>,
Andrew Morton <akpm@linux-foundation.org>,
Alexey Dobriyan <adobriyan@gmail.com>
Subject: Re: [patch 2/4] proc: Show namespaces IDs in /proc/pid/ns/* files
Date: Tue, 03 Jan 2012 22:02:32 -0800 [thread overview]
Message-ID: <m1d3b0gg3r.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <20111223124920.725686255@openvz.org> (Cyrill Gorcunov's message of "Fri, 23 Dec 2011 16:47:43 +0400")
Cyrill Gorcunov <gorcunov@openvz.org> writes:
> This patch adds proc_ns_read method which provides
> IDs for /proc/pid/ns/* files.
Nacked-by: "Eric W. Biederman" <ebiederm@xmission.com>
This is a poorly thought out user interface. If we are going to return
this kind of information and I believe we should we should, we should
return the id in the inode field with stat.
Comparing device+inode for equality is the traditional way to see if
two objects are the same in unix and there is no reason to make up
a new interface to get this functionality.
Furthermore we should always return the information, as it is valuable
even outside of the checkpoint/restart context.
I am also concerned that you appear to be building an interface
for use by checkpoint/restart that makes it impossible
checkpoint/restart the programs using that interface. The reason
is that you appear to be putting this nebulous id into a global
namespace and as such even if we wanted to I don't see how we could
build a version where we could restore the id during a restart. And
the thing is if you start building interfaces with identifiers you can
not possibly restore I expect you will find you have painted yourself
into a corner.
Using inode from stat avoids painting yourself into a corner because
you have the possibility of different mounts with different device
numbers having different inode numbers.
For the short term I don't see value in being able to restore the
object identifiers, but I do see a lot of value in allowing for a future
where nested checkpoint/restart is an option.
Eric
> Based-on-patch-from: Pavel Emelyanov <xemul@parallels.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
> CC: Glauber Costa <glommer@parallels.com>
> CC: Andi Kleen <andi@firstfloor.org>
> CC: Tejun Heo <tj@kernel.org>
> CC: Matt Helsley <matthltc@us.ibm.com>
> CC: Pekka Enberg <penberg@kernel.org>
> CC: Eric Dumazet <eric.dumazet@gmail.com>
> CC: Vasiliy Kulikov <segoon@openwall.com>
> CC: Andrew Morton <akpm@linux-foundation.org>
> CC: Alexey Dobriyan <adobriyan@gmail.com>
> ---
> Documentation/filesystems/proc.txt | 24 ++++++++++++++++++++++++
> fs/proc/namespaces.c | 22 ++++++++++++++++++++++
> include/linux/gen_obj_id.h | 1 +
> 3 files changed, 47 insertions(+)
>
> Index: linux-2.6.git/Documentation/filesystems/proc.txt
> ===================================================================
> --- linux-2.6.git.orig/Documentation/filesystems/proc.txt
> +++ linux-2.6.git/Documentation/filesystems/proc.txt
> @@ -40,6 +40,7 @@ Table of Contents
> 3.4 /proc/<pid>/coredump_filter - Core dump filtering settings
> 3.5 /proc/<pid>/mountinfo - Information about mounts
> 3.6 /proc/<pid>/comm & /proc/<pid>/task/<tid>/comm
> + 3.7 /proc/<pid>/ns - Information about namespaces
>
>
> ------------------------------------------------------------------------------
> @@ -1545,3 +1546,26 @@ a task to set its own or one of its thre
> is limited in size compared to the cmdline value, so writing anything longer
> then the kernel's TASK_COMM_LEN (currently 16 chars) will result in a truncated
> comm value.
> +
> +3.7 /proc/<pid>/ns - Information about namespaces
> +-----------------------------------------------------
> +
> +This directory consists of the following files "net", "uts", "ipc",
> +and depend if appropriate CONFIG_ entry is set, i.e. it's possible
> +to have only one, two or all three files here.
> +
> +Currently file contents provides that named "object id" number, which
> +is a number useful for the one purpose only -- to test if two differen
> +<pid> share the namespace.
> +
> +A typical format is
> +
> +id: 445332486300860161
> +
> +i.e. "id" followed by a number. One should never assume the number
> +means something, it is only useful for "sameness" test with another number
> +obtained from another <pid>.
> +
> +Moreover, a safe approach is to remember it as a string, since format may
> +change in future and id would be not a long integer value, but something
> +else, say SHA1/2 or even uuid encoded stream.
> Index: linux-2.6.git/fs/proc/namespaces.c
> ===================================================================
> --- linux-2.6.git.orig/fs/proc/namespaces.c
> +++ linux-2.6.git/fs/proc/namespaces.c
> @@ -12,6 +12,7 @@
> #include <linux/mnt_namespace.h>
> #include <linux/ipc_namespace.h>
> #include <linux/pid_namespace.h>
> +#include <linux/gen_obj_id.h>
> #include "internal.h"
>
>
> @@ -27,10 +28,31 @@ static const struct proc_ns_operations *
> #endif
> };
>
> +#ifdef CONFIG_GENERIC_OBJECT_ID
> +static ssize_t proc_ns_read(struct file *file, char __user *buf,
> + size_t len, loff_t *ppos)
> +{
> + struct proc_inode *ei = PROC_I(file->f_dentry->d_inode);
> + char tmp[32];
> +
> + snprintf(tmp, sizeof(tmp), "id:\t%lu\n",
> + gen_obj_id(ei->ns, GEN_OBJ_ID_NS));
> + return simple_read_from_buffer(buf, len, ppos, tmp, strlen(tmp));
> +}
> +
> +static const struct file_operations ns_file_operations = {
> + .llseek = no_llseek,
> + .read = proc_ns_read,
> +};
> +
> +#else
> +
> static const struct file_operations ns_file_operations = {
> .llseek = no_llseek,
> };
>
> +#endif /* CONFIG_GENERIC_OBJECT_ID */
> +
> static struct dentry *proc_ns_instantiate(struct inode *dir,
> struct dentry *dentry, struct task_struct *task, const void *ptr)
> {
> Index: linux-2.6.git/include/linux/gen_obj_id.h
> ===================================================================
> --- linux-2.6.git.orig/include/linux/gen_obj_id.h
> +++ linux-2.6.git/include/linux/gen_obj_id.h
> @@ -4,6 +4,7 @@
> #ifdef __KERNEL__
>
> enum {
> + GEN_OBJ_ID_NS,
> GEN_OBJ_ID_TYPES,
> };
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2012-01-04 6:00 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-23 12:47 [patch 0/4] generic object ids, v2 Cyrill Gorcunov
2011-12-23 12:47 ` [patch 1/4] Add routine for generating an ID for kernel pointer Cyrill Gorcunov
2011-12-27 23:23 ` Andrew Morton
2011-12-28 7:42 ` Cyrill Gorcunov
2011-12-28 9:42 ` Andrew Morton
2011-12-28 9:43 ` Cyrill Gorcunov
2011-12-28 9:47 ` Pavel Emelyanov
2011-12-28 10:41 ` Cyrill Gorcunov
2011-12-27 23:33 ` Andrew Morton
2011-12-28 0:48 ` Randy Dunlap
2011-12-28 7:24 ` Cyrill Gorcunov
2011-12-27 23:54 ` Valdis.Kletnieks
2011-12-28 0:02 ` Andrew Morton
2011-12-28 7:22 ` Cyrill Gorcunov
2011-12-28 16:06 ` Tejun Heo
2011-12-28 16:18 ` Cyrill Gorcunov
2011-12-28 16:26 ` Tejun Heo
2011-12-28 16:40 ` Cyrill Gorcunov
2011-12-28 16:45 ` Tejun Heo
2011-12-28 16:53 ` Cyrill Gorcunov
2011-12-28 17:01 ` Tejun Heo
2011-12-28 17:14 ` Cyrill Gorcunov
2011-12-29 14:24 ` Cyrill Gorcunov
2011-12-29 16:14 ` Tejun Heo
2011-12-29 16:24 ` Cyrill Gorcunov
2011-12-30 0:23 ` Herbert Xu
2011-12-30 7:36 ` Cyrill Gorcunov
2011-12-30 20:31 ` KOSAKI Motohiro
2011-12-30 20:48 ` Cyrill Gorcunov
2011-12-30 23:51 ` KOSAKI Motohiro
2011-12-31 7:51 ` Cyrill Gorcunov
2012-01-02 12:18 ` bastien ROUCARIES
2012-01-02 21:14 ` Cyrill Gorcunov
2011-12-31 4:55 ` Kyle Moffett
2011-12-31 7:57 ` Cyrill Gorcunov
2011-12-23 12:47 ` [patch 2/4] proc: Show namespaces IDs in /proc/pid/ns/* files Cyrill Gorcunov
2012-01-04 6:02 ` Eric W. Biederman [this message]
2012-01-04 11:26 ` Cyrill Gorcunov
2012-01-04 17:56 ` Eric W. Biederman
2012-01-04 18:19 ` Cyrill Gorcunov
2011-12-23 12:47 ` [patch 3/4] proc: Show open file ID in /proc/pid/fdinfo/* Cyrill Gorcunov
2011-12-23 12:47 ` [patch 4/4] proc: Show IDs of objects cloned with CLONE_ in proc Cyrill Gorcunov
-- strict thread matches above, loose matches on Subject: below --
2011-12-22 12:56 [patch 0/4] kernel generic object IDs series Cyrill Gorcunov
2011-12-22 12:56 ` [patch 2/4] proc: Show namespaces IDs in /proc/pid/ns/* files Cyrill Gorcunov
2011-11-17 9:55 [PATCH v2 0/4] Checkpoint/Restore: Show in proc IDs of objects that can be shared between tasks Pavel Emelyanov
2011-11-17 9:56 ` [PATCH 2/4] proc: Show namespaces IDs in /proc/pid/ns/* files Pavel Emelyanov
2011-11-15 11:35 [PATCH 0/4] Checkpoint/Restore: Show in proc IDs of objects that can be shared between tasks Pavel Emelyanov
2011-11-15 11:36 ` [PATCH 2/4] proc: Show namespaces IDs in /proc/pid/ns/* files Pavel Emelyanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1d3b0gg3r.fsf@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=eric.dumazet@gmail.com \
--cc=glommer@parallels.com \
--cc=gorcunov@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthltc@us.ibm.com \
--cc=penberg@kernel.org \
--cc=segoon@openwall.com \
--cc=tj@kernel.org \
--cc=xemul@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.