From: Tejun Heo Subject: Re: [PATCH 2/2] cgroup: make css->refcnt clearing on cgroup removal optional Date: Wed, 23 May 2012 15:22:42 -0700 Message-ID: <20120523222242.GD3933@htj.dyndns.org> References: <20120330223423.GJ28934@google.com> <20120330223606.GK28934@google.com> <4F77B6BA.4070207@huawei.com> <20120401185430.GA9230@dhcp-172-17-108-109.mtv.corp.google.com> <20120518175548.GM19388@google.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=FSkVrmppXGqOQKhdQVrA8TZ0Qs8vI5rHrpndARHtCLk=; b=SPU3I+4dIGQ9UbpHnNZiiZrP9/XsK+NoXneyoFEUXVXSojbxSo/Lxe6w4XOSws6csv 48wSx3Up3UmYZtRgZX24Y1/qGPRcBjiLwGlDRRbo2SdQJoZzWRYtFABIxm4rEyzThXmk a8667VG05Z9SJy9J6+i7Cl/BqjHPfBqUj1SyI2L0BIYPYSHLH2QEjCXdtlLN3oT1yYRq UMqT+/97yaQV3RU9YZcVqIh1DEuw4XX0Z7mQgdnwpkSXpFJxFX+YurP3MDJWgge6cm9t wDN+lxN3rPVRU2MFnV3Ju+vqBOUaY/04jwu1O1OkA1p6+wac/qNqPVy/GIiWWAymRXqR dmBA== Content-Disposition: inline In-Reply-To: Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Sasha Levin Cc: Li Zefan , containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, fweisbec-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, rni-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, ctalbott-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, Vivek Goyal , Johannes Weiner , Michal Hocko , Balbir Singh , KAMEZAWA Hiroyuki Hello, Sasha. Does the following patch fix the problem you're seeing? Thanks. --- kernel/cgroup.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/kernel/cgroup.c b/kernel/cgroup.c index ad8eae5..7cf9669 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -896,10 +896,13 @@ static void cgroup_diput(struct dentry *dentry, struct inode *inode) mutex_unlock(&cgroup_mutex); /* - * Drop the active superblock reference that we took when we - * created the cgroup + * We want to drop the active superblock reference that we + * took when we created the cgroup after all dentry refs + * are gone - kill_sb gets mighty unhappy otherwise. Set + * dentry->d_fsdata to cgroup_diput() to tell + * cgroup_d_release() to call deactivate_super(). */ - deactivate_super(cgrp->root->sb); + dentry->d_fsdata = cgroup_diput; /* * if we're getting rid of the cgroup, refcount should ensure @@ -925,6 +928,13 @@ static int cgroup_delete(const struct dentry *d) return 1; } +static void cgroup_d_release(struct dentry *dentry) +{ + /* did cgroup_diput() tell me to deactivate super? */ + if (dentry->d_fsdata == cgroup_diput) + deactivate_super(dentry->d_sb); +} + static void remove_dir(struct dentry *d) { struct dentry *parent = dget(d->d_parent); @@ -1532,6 +1542,7 @@ static int cgroup_get_rootdir(struct super_block *sb) static const struct dentry_operations cgroup_dops = { .d_iput = cgroup_diput, .d_delete = cgroup_delete, + .d_release = cgroup_d_release, }; struct inode *inode =