Re: task containersv11 kernel BUG at include/linux/dcache.h:323

From: Paul Menage
Date: Mon Sep 17 2007 - 15:24:46 EST


On 9/17/07, Paul Jackson <pj@xxxxxxx> wrote:
> Paul M wrote:
> > This is already fixed in -mm
>
> I'm missing a clue ... the latest *-mm below
>
> ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/
>
> I see is:
>
> 2.6.23-rc4/2.6.23-rc4-mm1/
>
> dated two weeks ago, without this fix.
>
> I also don't see any mention of this fix in any recent
> lkml or linux-mm mailing list messages.
>
> What am I missing? Where is this patch?

It was just last week - it went to the containers list and not the
entire lkml. I've attached the patch.

Paul
Fix a reference counting bug in containerfs

As part of the extraction of cpusetfs to containerfs, a call to
cpuset_get_dentry() was lost (justified by the fact that the dentry in
question was now being passed down by the caller). Since
cpuset_get_dentry() called lookup_one_len(), this resulted in a
reference count being missed from the directory dentry.

This patch removes container_get_dentry() and replaces it with direct
calls to lookup_one_len(); the initialization of containerfs dentry
ops is done now in container_create_file() at dentry creation time.

Signed-off-by: Paul Menage <menage@xxxxxxxxxx>

---
kernel/container.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)

Index: container-2.6.23-rc4-mm1/kernel/container.c
===================================================================
--- container-2.6.23-rc4-mm1.orig/kernel/container.c
+++ container-2.6.23-rc4-mm1/kernel/container.c
@@ -604,19 +604,6 @@ static void container_diput(struct dentr
iput(inode);
}

-static struct dentry *container_get_dentry(struct dentry *parent,
- const char *name)
-{
- struct dentry *d = lookup_one_len(name, parent, strlen(name));
- static struct dentry_operations container_dops = {
- .d_iput = container_diput,
- };
-
- if (!IS_ERR(d))
- d->d_op = &container_dops;
- return d;
-}
-
static void remove_dir(struct dentry *d)
{
struct dentry *parent = dget(d->d_parent);
@@ -1507,6 +1494,10 @@ static struct inode_operations container
static int container_create_file(struct dentry *dentry, int mode,
struct super_block *sb)
{
+ static struct dentry_operations container_dops = {
+ .d_iput = container_diput,
+ };
+
struct inode *inode;

if (!dentry)
@@ -1532,7 +1523,7 @@ static int container_create_file(struct
inode->i_size = 0;
inode->i_fop = &container_file_operations;
}
-
+ dentry->d_op = &container_dops;
d_instantiate(dentry, inode);
dget(dentry); /* Extra count - pin the dentry in core */
return 0;
@@ -1553,13 +1544,12 @@ static int container_create_dir(struct c
int error = 0;

parent = cont->parent->dentry;
- if (IS_ERR(dentry))
- return PTR_ERR(dentry);
error = container_create_file(dentry, S_IFDIR | mode, cont->root->sb);
if (!error) {
dentry->d_fsdata = cont;
inc_nlink(parent->d_inode);
cont->dentry = dentry;
+ dget(dentry);
}
dput(dentry);

@@ -1581,7 +1571,7 @@ int container_add_file(struct container
}
strcat(name, cft->name);
BUG_ON(!mutex_is_locked(&dir->d_inode->i_mutex));
- dentry = container_get_dentry(dir, name);
+ dentry = lookup_one_len(name, dir, strlen(name));
if (!IS_ERR(dentry)) {
error = container_create_file(dentry, 0644 | S_IFREG,
cont->root->sb);
@@ -2587,7 +2577,7 @@ int container_clone(struct task_struct *
/* Hold the parent directory mutex across this operation to
* stop anyone else deleting the new container */
mutex_lock(&inode->i_mutex);
- dentry = container_get_dentry(parent->dentry, nodename);
+ dentry = lookup_one_len(nodename, parent->dentry, strlen(nodename));
if (IS_ERR(dentry)) {
printk(KERN_INFO
"Couldn't allocate dentry for %s: %ld\n", nodename,