All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
To: Hillf Danton <dhillf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Lennart Poettering
	<mzxreary-uLTowLwuiw4b1SvskN2V4Q@public.gmane.org>,
	Kay Sievers <kay.sievers-tD+1rO4QERM@public.gmane.org>,
	Hugh Dickins <hughd-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Cgroups <cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Eric Paris <eparis-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
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-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

20:48, Hillf Danton wrote:
> On Thu, Mar 1, 2012 at 2:17 PM, Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> 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);
>>  }
>>

WARNING: multiple messages have this Message-ID (diff)
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);
>>  }
>>

  parent reply	other threads:[~2012-03-02  5:49 UTC|newest]

Thread overview: 20+ 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 3/3] " Li Zefan
     [not found] ` <4F4F1459.4080300-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2012-03-01  6:17   ` [PATCH v2 1/3] xattr: extract kmem_xattr code from tmpfs Li Zefan
2012-03-01  6:17     ` Li Zefan
     [not found]     ` <4F4F146C.9090300-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2012-03-01 12:42       ` Hillf Danton
2012-03-01 12:42         ` Hillf Danton
     [not found]         ` <CAJd=RBB+2r-Q8K1FQqPh90EdtAdmz3R8FWU48M_ePqyziNfcLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-02  5:23           ` Li Zefan
2012-03-02  5:23             ` Li Zefan
2012-03-01  6:17   ` [PATCH v2 2/3] cgroup: revise how we re-populate root directory Li Zefan
2012-03-01  6:17     ` Li Zefan
     [not found]     ` <4F4F148F.6040808-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2012-03-01 12:48       ` Hillf Danton
2012-03-01 12:48         ` Hillf Danton
     [not found]         ` <CAJd=RBAh-GzsfMiViGzKMeDV+G01K_OHZQHJ=amnp0trVhMABQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-02  5:49           ` Li Zefan [this message]
2012-03-02  5:49             ` Li Zefan
2012-03-04 18:05   ` [PATCH v2 0/3] cgroup: add xattr support Tejun Heo
2012-03-04 18:05     ` Tejun Heo
     [not found]     ` <20120304180516.GB20787-RcKxWJ4Cfj1J2suj2OqeGauc2jM2gXBXkQQo+JxHRPFibQn6LdNjmg@public.gmane.org>
2012-03-06 21:37       ` Hugh Dickins
2012-03-06 21:37         ` Hugh Dickins
2012-03-08  9:03       ` Li Zefan
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-bthxqxjhjhxqfuhtdcdx3a@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dhillf-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=eparis-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=hughd-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=kay.sievers-tD+1rO4QERM@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mzxreary-uLTowLwuiw4b1SvskN2V4Q@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.