From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
Alexey Dobriyan <adobriyan@gmail.com>,
Al Viro <viro@ZenIV.linux.org.uk>,
Linux Containers <containers@lists.osdl.org>
Subject: [PATCH 2/7] proc: Implement support for automounts in task directories
Date: Thu, 06 Nov 2008 02:48:35 -0800 [thread overview]
Message-ID: <m1abcd2kqk.fsf@frodo.ebiederm.org> (raw)
In-Reply-To: <m1ej1p2l6u.fsf@frodo.ebiederm.org> (Eric W. Biederman's message of "Thu, 06 Nov 2008 02:38:49 -0800")
This is a genearl 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>
---
fs/proc/Makefile | 1 +
fs/proc/automount.c | 29 +++++++++++++++++++++++++++++
fs/proc/internal.h | 3 +++
include/linux/proc_fs.h | 1 +
kernel/exit.c | 1 +
5 files changed, 35 insertions(+), 0 deletions(-)
create mode 100644 fs/proc/automount.c
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index 63d9651..862a8fe 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -18,6 +18,7 @@ proc-y += meminfo.o
proc-y += stat.o
proc-y += uptime.o
proc-y += version.o
+proc-y += automount.o
proc-$(CONFIG_PROC_SYSCTL) += proc_sysctl.o
proc-$(CONFIG_NET) += proc_net.o
proc-$(CONFIG_PROC_KCORE) += kcore.o
diff --git a/fs/proc/automount.c b/fs/proc/automount.c
new file mode 100644
index 0000000..a1fabf2
--- /dev/null
+++ b/fs/proc/automount.c
@@ -0,0 +1,29 @@
+#include <linux/workqueue.h>
+#include <linux/mount.h>
+#include <linux/vfs.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..2a8eabb 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -93,3 +93,6 @@ 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..3505a72 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);
diff --git a/kernel/exit.c b/kernel/exit.c
index 80137a5..8a8badb 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -161,6 +161,7 @@ void release_task(struct task_struct * p)
repeat:
tracehook_prepare_release_task(p);
atomic_dec(&p->user->processes);
+ proc_shrink_automounts();
proc_flush_task(p);
write_lock_irq(&tasklist_lock);
tracehook_finish_release_task(p);
--
1.5.3.rc6.17.g1911
WARNING: multiple messages have this Message-ID (diff)
From: ebiederm@xmission.com (Eric W. Biederman)
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>,
Alexey Dobriyan <adobriyan@gmail.com>,
Al Viro <viro@ZenIV.linux.org.uk>,
Linux Containers <containers@lists.osdl.org>
Subject: [PATCH 2/7] proc: Implement support for automounts in task directories
Date: Thu, 06 Nov 2008 02:48:35 -0800 [thread overview]
Message-ID: <m1abcd2kqk.fsf@frodo.ebiederm.org> (raw)
In-Reply-To: <m1ej1p2l6u.fsf@frodo.ebiederm.org> (Eric W. Biederman's message of "Thu, 06 Nov 2008 02:38:49 -0800")
This is a genearl 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>
---
fs/proc/Makefile | 1 +
fs/proc/automount.c | 29 +++++++++++++++++++++++++++++
fs/proc/internal.h | 3 +++
include/linux/proc_fs.h | 1 +
kernel/exit.c | 1 +
5 files changed, 35 insertions(+), 0 deletions(-)
create mode 100644 fs/proc/automount.c
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index 63d9651..862a8fe 100644
--- a/fs/proc/Makefile
+++ b/fs/proc/Makefile
@@ -18,6 +18,7 @@ proc-y += meminfo.o
proc-y += stat.o
proc-y += uptime.o
proc-y += version.o
+proc-y += automount.o
proc-$(CONFIG_PROC_SYSCTL) += proc_sysctl.o
proc-$(CONFIG_NET) += proc_net.o
proc-$(CONFIG_PROC_KCORE) += kcore.o
diff --git a/fs/proc/automount.c b/fs/proc/automount.c
new file mode 100644
index 0000000..a1fabf2
--- /dev/null
+++ b/fs/proc/automount.c
@@ -0,0 +1,29 @@
+#include <linux/workqueue.h>
+#include <linux/mount.h>
+#include <linux/vfs.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..2a8eabb 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -93,3 +93,6 @@ 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..3505a72 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);
diff --git a/kernel/exit.c b/kernel/exit.c
index 80137a5..8a8badb 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -161,6 +161,7 @@ void release_task(struct task_struct * p)
repeat:
tracehook_prepare_release_task(p);
atomic_dec(&p->user->processes);
+ proc_shrink_automounts();
proc_flush_task(p);
write_lock_irq(&tasklist_lock);
tracehook_finish_release_task(p);
--
1.5.3.rc6.17.g1911
next prev parent reply other threads:[~2008-11-06 10:48 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-06 10:38 [PATCH 1/7] vfs: Fix shrink_submounts Eric W. Biederman
2008-11-06 10:38 ` Eric W. Biederman
2008-11-06 10:48 ` Eric W. Biederman [this message]
2008-11-06 10:48 ` [PATCH 2/7] proc: Implement support for automounts in task directories Eric W. Biederman
[not found] ` <m1abcd2kqk.fsf-B27657KtZYmhTnVgQlOflh2eb7JE58TQ@public.gmane.org>
2008-11-06 10:49 ` [PATCH 3/7] proc: Support multiple filesystems using the proc generic infrastructure Eric W. Biederman
2008-11-06 10:49 ` Eric W. Biederman
[not found] ` <m163n12ko9.fsf_-_-B27657KtZYmhTnVgQlOflh2eb7JE58TQ@public.gmane.org>
2008-11-06 10:53 ` [PATCH 4/7] proc: Make /proc/net it's own filesystem Eric W. Biederman
2008-11-06 10:53 ` Eric W. Biederman
[not found] ` <m1y6zx15yj.fsf_-_-B27657KtZYmhTnVgQlOflh2eb7JE58TQ@public.gmane.org>
2008-11-06 10:56 ` [PATCH 5/7] proc_net: Don't show the wrong /proc/net after unshare Eric W. Biederman
2008-11-06 10:56 ` Eric W. Biederman
[not found] ` <m1skq515ti.fsf_-_-B27657KtZYmhTnVgQlOflh2eb7JE58TQ@public.gmane.org>
2008-11-06 10:57 ` [PATCH 6/7] proc_net: Simplify network namespace lookup Eric W. Biederman
2008-11-06 10:57 ` Eric W. Biederman
2008-11-06 10:58 ` [PATCH 7/7] proc: Cleanup proc_flush_task Eric W. Biederman
2008-11-06 10:58 ` Eric W. Biederman
2008-11-07 1:25 ` [PATCH 2/7] proc: Implement support for automounts in task directories Andrew Morton
2008-11-07 1:25 ` Andrew Morton
2008-11-07 2:02 ` Eric W. Biederman
2008-11-07 1:26 ` Andrew Morton
2008-11-07 1:26 ` Andrew Morton
2008-11-07 2:05 ` Eric W. Biederman
2008-11-07 2:49 ` Andrew Morton
2008-11-07 2:49 ` Andrew Morton
2008-11-07 3:51 ` Eric W. Biederman
2008-11-07 4:28 ` Andrew Morton
2008-11-07 4:28 ` Andrew Morton
2008-11-07 15:51 ` Eric W. Biederman
2008-11-07 16:05 ` Andrew Morton
2008-11-07 16:05 ` Andrew Morton
2008-11-07 16:58 ` Eric W. Biederman
2008-11-13 23:39 ` Eric W. Biederman
2008-11-19 0:07 ` Alexey Dobriyan
2008-11-19 2:35 ` Alexey Dobriyan
2008-11-19 13:20 ` Eric W. Biederman
2008-11-07 4:41 ` Alexey Dobriyan
2008-11-07 16:04 ` [PATCH] proc: Supply proc_shrink_automounts when CONFIG_PROC_FS=N Eric W. Biederman
2008-11-07 1:22 ` [PATCH 1/7] vfs: Fix shrink_submounts Andrew Morton
2008-11-07 1:22 ` Andrew Morton
2008-11-07 2:06 ` Eric W. Biederman
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=m1abcd2kqk.fsf@frodo.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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.