Linux Container Development
 help / color / mirror / Atom feed
* [PATCH 1/6] proc: implement support for automounts in task directories
@ 2009-01-05 23:32 Alexey Dobriyan
  2009-01-05 23:36 ` Alexey Dobriyan
  2009-01-06  9:21 ` Christoph Hellwig
  0 siblings, 2 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2009-01-05 23:32 UTC (permalink / raw)
  To: ebiederm, viro; +Cc: linux-kernel, containers, sds, jmorris

This is current version of /proc/net as separate file system patchset,
rebased, etc. I'll put it into -next again when merge window closes.

Please, review.
----------------------------------------------------------------------
From a934c391e19837e760592536c4cdd1b4f2432caa Mon Sep 17 00:00:00 2001
From: Eric W. Biederman <ebiederm@xmission.com>
Date: Wed, 19 Nov 2008 03:57:02 +0300
Subject: [PATCH 1/6] proc: implement support for automounts in task directories

This is a general mechanism that is capable of removing any unused mounts on
/proc in any directory.  As we flush the mounts when a processes dies this
mechanism is tailored for flushing mounts in the per task and per task group
directories.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 fs/proc/Makefile        |    1 +
 fs/proc/automount.c     |   28 ++++++++++++++++++++++++++++
 fs/proc/internal.h      |    2 ++
 include/linux/proc_fs.h |    5 +++++
 kernel/exit.c           |    2 +-
 5 files changed, 37 insertions(+), 1 deletions(-)
 create mode 100644 fs/proc/automount.c

diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index 63d9651..757f7c1 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -9,6 +9,7 @@ proc-$(CONFIG_MMU)	:= mmu.o task_mmu.o
 
 proc-y       += inode.o root.o base.o generic.o array.o \
 		proc_tty.o
+proc-y	+= automount.o
 proc-y	+= cmdline.o
 proc-y	+= cpuinfo.o
 proc-y	+= devices.o
diff --git a/fs/proc/automount.c b/fs/proc/automount.c
new file mode 100644
index 0000000..5d22b5a
--- /dev/null
+++ b/fs/proc/automount.c
@@ -0,0 +1,28 @@
+#include <linux/list.h>
+#include <linux/mount.h>
+#include <linux/workqueue.h>
+#include "internal.h"
+
+LIST_HEAD(proc_automounts);
+
+static void proc_expire_automounts(struct work_struct *work);
+
+static DECLARE_DELAYED_WORK(proc_automount_task, proc_expire_automounts);
+static int proc_automount_timeout = 500 * HZ;
+
+void proc_shrink_automounts(void)
+{
+	struct list_head *list = &proc_automounts;
+
+	mark_mounts_for_expiry(list);
+	mark_mounts_for_expiry(list);
+	if (list_empty(list))
+		return;
+
+	schedule_delayed_work(&proc_automount_task, proc_automount_timeout);
+}
+
+static void proc_expire_automounts(struct work_struct *work)
+{
+	proc_shrink_automounts();
+}
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 3e8aeb8..314c0d3 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -93,3 +93,5 @@ struct pde_opener {
 	int (*release)(struct inode *, struct file *);
 	struct list_head lh;
 };
+
+extern struct list_head proc_automounts;
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index b8bdb96..768e627 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -101,6 +101,7 @@ extern spinlock_t proc_subdir_lock;
 
 extern void proc_root_init(void);
 
+void proc_shrink_automounts(void);
 void proc_flush_task(struct task_struct *task);
 struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *);
 int proc_pid_readdir(struct file * filp, void * dirent, filldir_t filldir);
@@ -207,6 +208,10 @@ static inline void proc_flush_task(struct task_struct *task)
 {
 }
 
+static inline void proc_shrink_automounts(void)
+{
+}
+
 static inline struct proc_dir_entry *create_proc_entry(const char *name,
 	mode_t mode, struct proc_dir_entry *parent) { return NULL; }
 static inline struct proc_dir_entry *proc_create(const char *name,
diff --git a/kernel/exit.c b/kernel/exit.c
index c9e5a1c..640b3bb 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -173,7 +173,7 @@ repeat:
 	/* don't need to get the RCU readlock here - the process is dead and
 	 * can't be modifying its own credentials */
 	atomic_dec(&__task_cred(p)->user->processes);
-
+	proc_shrink_automounts();
 	proc_flush_task(p);
 	write_lock_irq(&tasklist_lock);
 	tracehook_finish_release_task(p);
-- 
1.5.6.5

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

* Re: [PATCH 1/6] proc: implement support for automounts in task directories
  2009-01-05 23:32 [PATCH 1/6] proc: implement support for automounts in task directories Alexey Dobriyan
@ 2009-01-05 23:36 ` Alexey Dobriyan
  2009-01-06  9:21 ` Christoph Hellwig
  1 sibling, 0 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2009-01-05 23:36 UTC (permalink / raw)
  To: ebiederm, viro; +Cc: linux-kernel, containers, sds, jmorris

On Tue, Jan 06, 2009 at 02:32:41AM +0300, Alexey Dobriyan wrote:
> This is current version of /proc/net as separate file system patchset,
> rebased, etc. I'll put it into -next again when merge window closes.

Currently everything is at

	git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc.git proc-wip

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

* Re: [PATCH 1/6] proc: implement support for automounts in task directories
  2009-01-05 23:32 [PATCH 1/6] proc: implement support for automounts in task directories Alexey Dobriyan
  2009-01-05 23:36 ` Alexey Dobriyan
@ 2009-01-06  9:21 ` Christoph Hellwig
  2009-01-06 12:20   ` Eric W. Biederman
  1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2009-01-06  9:21 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: ebiederm, viro, linux-kernel, containers, sds, jmorris

On Tue, Jan 06, 2009 at 02:32:41AM +0300, Alexey Dobriyan wrote:
> This is current version of /proc/net as separate file system patchset,
> rebased, etc. I'll put it into -next again when merge window closes.

I still don't see the point for that.  Why not /proc/nets/<netid> with
symlinks from /proc/<pid>/net into those?

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

* Re: [PATCH 1/6] proc: implement support for automounts in task directories
  2009-01-06  9:21 ` Christoph Hellwig
@ 2009-01-06 12:20   ` Eric W. Biederman
  0 siblings, 0 replies; 4+ messages in thread
From: Eric W. Biederman @ 2009-01-06 12:20 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Alexey Dobriyan, viro, linux-kernel, containers, sds, jmorris

Christoph Hellwig <hch@infradead.org> writes:

> On Tue, Jan 06, 2009 at 02:32:41AM +0300, Alexey Dobriyan wrote:
>> This is current version of /proc/net as separate file system patchset,
>> rebased, etc. I'll put it into -next again when merge window closes.
>
> I still don't see the point for that.  Why not /proc/nets/<netid> with
> symlinks from /proc/<pid>/net into those?

Simple really.

/proc/nets/<netid> is the other possible viable solution.  Where netid
is some pid value that we assign to the network namespace during
unshare or clone.  While there is precedent of using a pid value
to identify a process group or a session it is a bit of a stretch
to have it cover a namespace.

When I talked it over with Al his preference was to for the
current approach, and it happens to be my preference as well.

It gives more control of naming policy to user space allowing us to
avoid the maintenance pain that is sysfs where user space depends upon
a fixed kernel naming policy (which makes change hard).

It gives us a guarantee that we only have a single dentry tree for
any given network namespace.

It allows us to eventually separate out maintenance of proc/generic
and proc/net, as inherently they have nothing in common.

The only cost of this is that we actually use one of the rare but
fully supported vfs features, on demand submounts.

Beyond that proc has wanted to be several filesystems for ages, and doing
it this way allows us to actually start splitting proc up without breaking
backwards compatibility with out existing user space.

Eric

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

end of thread, other threads:[~2009-01-06 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-05 23:32 [PATCH 1/6] proc: implement support for automounts in task directories Alexey Dobriyan
2009-01-05 23:36 ` Alexey Dobriyan
2009-01-06  9:21 ` Christoph Hellwig
2009-01-06 12:20   ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox