From: Li Zefan <lizf@cn.fujitsu.com>
To: Hillf Danton <dhillf@gmail.com>
Cc: Tejun Heo <tj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Lennart Poettering <mzxreary@0pointer.de>,
Kay Sievers <kay.sievers@vrfy.org>,
Hugh Dickins <hughd@google.com>,
LKML <linux-kernel@vger.kernel.org>,
Cgroups <cgroups@vger.kernel.org>, Eric Paris <eparis@redhat.com>
Subject: Re: [PATCH v2 2/3] cgroup: revise how we re-populate root directory
Date: Fri, 02 Mar 2012 13:49:06 +0800 [thread overview]
Message-ID: <4F505F52.9000509@cn.fujitsu.com> (raw)
In-Reply-To: <CAJd=RBAh-GzsfMiViGzKMeDV+G01K_OHZQHJ=amnp0trVhMABQ@mail.gmail.com>
20:48, Hillf Danton wrote:
> On Thu, Mar 1, 2012 at 2:17 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>>
>> -static void cgroup_clear_directory(struct dentry *dentry)
>> +static void cgroup_clear_directory(struct dentry *dentry, bool remove_all,
>> + unsigned long removed_bits)
>> {
>> - struct list_head *node;
>> + LIST_HEAD(head);
>> + struct dentry *d, *node;
>>
>> BUG_ON(!mutex_is_locked(&dentry->d_inode->i_mutex));
>> +
>> spin_lock(&dentry->d_lock);
>> - node = dentry->d_subdirs.next;
>> - while (node != &dentry->d_subdirs) {
>> - struct dentry *d = list_entry(node, struct dentry, d_u.d_child);
>> + list_for_each_entry_safe(d, node, &dentry->d_subdirs, d_u.d_child) {
>> + struct cftype *cft = d->d_fsdata;
>> +
>> + if (!remove_all && cft->subsys &&
>> + !test_bit(cft->subsys->subsys_id, &removed_bits))
>> + continue;
>>
>> spin_lock_nested(&d->d_lock, DENTRY_D_LOCK_NESTED);
>> - list_del_init(node);
>> + list_move(&d->d_u.d_child, &head);
>> if (d->d_inode) {
>> /* This should never be called on a cgroup
>> * directory with child cgroups */
>> BUG_ON(d->d_inode->i_mode & S_IFDIR);
>> dget_dlock(d);
>> - spin_unlock(&d->d_lock);
>> - spin_unlock(&dentry->d_lock);
>> + }
>> + spin_unlock(&d->d_lock);
>> + }
>> + spin_unlock(&dentry->d_lock);
>> +
>
> Safe to process isolated entries without dentry->d_lock held?
>
no vfs expert, I need to check into the vfs code.
> -hd
>
>> + list_for_each_entry_safe(d, node, &head, d_u.d_child) {
>> + spin_lock(&d->d_lock);
>> + list_del_init(&d->d_u.d_child);
>> + spin_unlock(&d->d_lock);
>> + if (d->d_inode) {
>> d_delete(d);
>> simple_unlink(dentry->d_inode, d);
>> dput(d);
>> - spin_lock(&dentry->d_lock);
>> - } else
>> - spin_unlock(&d->d_lock);
>> - node = dentry->d_subdirs.next;
>> + }
>> }
>> - spin_unlock(&dentry->d_lock);
>> }
>>
next prev parent reply other threads:[~2012-03-02 5:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-01 6:16 [PATCH v2 0/3] cgroup: add xattr support Li Zefan
2012-03-01 6:17 ` [PATCH v2 1/3] xattr: extract kmem_xattr code from tmpfs Li Zefan
2012-03-01 12:42 ` Hillf Danton
2012-03-02 5:23 ` Li Zefan
2012-03-01 6:17 ` [PATCH v2 3/3] cgroup: add xattr support Li Zefan
2012-03-01 6:17 ` [PATCH v2 2/3] cgroup: revise how we re-populate root directory Li Zefan
2012-03-01 12:48 ` Hillf Danton
2012-03-02 5:49 ` Li Zefan [this message]
2012-03-04 18:05 ` [PATCH v2 0/3] cgroup: add xattr support Tejun Heo
2012-03-06 21:37 ` Hugh Dickins
2012-03-08 9:03 ` Li Zefan
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=4F505F52.9000509@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=dhillf@gmail.com \
--cc=eparis@redhat.com \
--cc=hughd@google.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mzxreary@0pointer.de \
--cc=tj@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox