From b192171a77f3a681ff3d32c13afaeea7ba1e8003 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 6 Dec 2006 20:38:45 -0800 Subject: [PATCH] --- yaml --- r: 42887 b: refs/heads/master c: d18de5a2721f84ffd6a5d637915746ed47becc1c h: refs/heads/master i: 42885: 177a73f78142dfeb69a7569ceb97efd73bfa3747 42883: 1dfd337a496253779957a0bcb262d3f90aa22014 42879: 4862dfc739285f072f5aa8f2f240cbde93db4654 v: v3 --- [refs] | 2 +- trunk/fs/pipe.c | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index 3137e2d74cba..9ab4fa5a5b7f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 1c69d921ed9cc6593ad4f60c0f9951cb0d62b0b4 +refs/heads/master: d18de5a2721f84ffd6a5d637915746ed47becc1c diff --git a/trunk/fs/pipe.c b/trunk/fs/pipe.c index b1626f269a34..ae36b89b1a37 100644 --- a/trunk/fs/pipe.c +++ b/trunk/fs/pipe.c @@ -830,7 +830,14 @@ void free_pipe_info(struct inode *inode) static struct vfsmount *pipe_mnt __read_mostly; static int pipefs_delete_dentry(struct dentry *dentry) { - return 1; + /* + * At creation time, we pretended this dentry was hashed + * (by clearing DCACHE_UNHASHED bit in d_flags) + * At delete time, we restore the truth : not hashed. + * (so that dput() can proceed correctly) + */ + dentry->d_flags |= DCACHE_UNHASHED; + return 0; } static struct dentry_operations pipefs_dentry_operations = { @@ -891,17 +898,22 @@ struct file *create_write_pipe(void) if (!inode) goto err_file; - sprintf(name, "[%lu]", inode->i_ino); + this.len = sprintf(name, "[%lu]", inode->i_ino); this.name = name; - this.len = strlen(name); - this.hash = inode->i_ino; /* will go */ + this.hash = 0; err = -ENOMEM; dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this); if (!dentry) goto err_inode; dentry->d_op = &pipefs_dentry_operations; - d_add(dentry, inode); + /* + * We dont want to publish this dentry into global dentry hash table. + * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED + * This permits a working /proc/$pid/fd/XXX on pipes + */ + dentry->d_flags &= ~DCACHE_UNHASHED; + d_instantiate(dentry, inode); f->f_vfsmnt = mntget(pipe_mnt); f->f_dentry = dentry; f->f_mapping = inode->i_mapping;