Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 71444
b: refs/heads/master
c: 60347f6
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Emelyanov authored and Linus Torvalds committed Oct 19, 2007
1 parent 2051d9c commit bd05107
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8bf9725c29f2589237dd696d06a204230add0ba3
refs/heads/master: 60347f6716aa49831ac311e04d77ccdc50dc024a
27 changes: 20 additions & 7 deletions trunk/fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include <linux/nsproxy.h>
#include <linux/oom.h>
#include <linux/elf.h>
#include <linux/pid_namespace.h>
#include "internal.h"

/* NOTE:
Expand Down Expand Up @@ -2204,27 +2205,27 @@ static const struct inode_operations proc_tgid_base_inode_operations = {
* that no dcache entries will exist at process exit time it
* just makes it very unlikely that any will persist.
*/
void proc_flush_task(struct task_struct *task)
static void proc_flush_task_mnt(struct vfsmount *mnt, pid_t pid, pid_t tgid)
{
struct dentry *dentry, *leader, *dir;
char buf[PROC_NUMBUF];
struct qstr name;

name.name = buf;
name.len = snprintf(buf, sizeof(buf), "%d", task->pid);
dentry = d_hash_and_lookup(proc_mnt->mnt_root, &name);
name.len = snprintf(buf, sizeof(buf), "%d", pid);
dentry = d_hash_and_lookup(mnt->mnt_root, &name);
if (dentry) {
shrink_dcache_parent(dentry);
d_drop(dentry);
dput(dentry);
}

if (thread_group_leader(task))
if (tgid == 0)
goto out;

name.name = buf;
name.len = snprintf(buf, sizeof(buf), "%d", task->tgid);
leader = d_hash_and_lookup(proc_mnt->mnt_root, &name);
name.len = snprintf(buf, sizeof(buf), "%d", tgid);
leader = d_hash_and_lookup(mnt->mnt_root, &name);
if (!leader)
goto out;

Expand All @@ -2235,7 +2236,7 @@ void proc_flush_task(struct task_struct *task)
goto out_put_leader;

name.name = buf;
name.len = snprintf(buf, sizeof(buf), "%d", task->pid);
name.len = snprintf(buf, sizeof(buf), "%d", pid);
dentry = d_hash_and_lookup(dir, &name);
if (dentry) {
shrink_dcache_parent(dentry);
Expand All @@ -2250,6 +2251,18 @@ void proc_flush_task(struct task_struct *task)
return;
}

/*
* when flushing dentries from proc one need to flush them from global
* proc (proc_mnt) and from all the namespaces' procs this task was seen
* in. this call is supposed to make all this job.
*/

void proc_flush_task(struct task_struct *task)
{
proc_flush_task_mnt(proc_mnt, task->pid,
thread_group_leader(task) ? 0 : task->tgid);
}

static struct dentry *proc_pid_instantiate(struct inode *dir,
struct dentry * dentry,
struct task_struct *task, const void *ptr)
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/linux/proc_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ extern void proc_net_remove(struct net *net, const char *name);
#define proc_net_create(net, name, mode, info) ({ (void)(mode), NULL; })
static inline void proc_net_remove(struct net *net, const char *name) {}

static inline void proc_flush_task(struct task_struct *task) { }
static inline void proc_flush_task(struct task_struct *task)
{
}

static inline struct proc_dir_entry *create_proc_entry(const char *name,
mode_t mode, struct proc_dir_entry *parent) { return NULL; }
Expand Down
2 changes: 1 addition & 1 deletion trunk/kernel/exit.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void release_task(struct task_struct * p)
int zap_leader;
repeat:
atomic_dec(&p->user->processes);
proc_flush_task(p);
write_lock_irq(&tasklist_lock);
ptrace_unlink(p);
BUG_ON(!list_empty(&p->ptrace_list) || !list_empty(&p->ptrace_children));
Expand Down Expand Up @@ -175,7 +176,6 @@ void release_task(struct task_struct * p)
}

write_unlock_irq(&tasklist_lock);
proc_flush_task(p);
release_thread(p);
call_rcu(&p->rcu, delayed_put_task_struct);

Expand Down

0 comments on commit bd05107

Please sign in to comment.