linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: Ian Kent <raven@themaw.net>,
	viro@zeniv.linux.org.uk, npiggin@kernel.dk,
	autofs@linux.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 09/18] autofs4: Add d_manage() dentry operation [ver #4]
Date: Sat, 15 Jan 2011 02:46:02 +1100	[thread overview]
Message-ID: <AANLkTin0YuRx9gRXLLJKOu4BOXYxOMnWmSsRLxAzXzdo@mail.gmail.com> (raw)
In-Reply-To: <5326.1295019354@redhat.com>

On Sat, Jan 15, 2011 at 2:35 AM, David Howells <dhowells@redhat.com> wrote:
> Nick Piggin <npiggin@gmail.com> wrote:
>
>> > On Thu, 2011-01-13 at 21:54 +0000, David Howells wrote:
>> >> From: Ian Kent <raven@themaw.net>
>> >> +     //spin_lock(&dcache_lock);  /////////////// JUST DELETE THIS LOCK?
>> >> +     if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
>> >> +             spin_lock(&dentry->d_lock);
>> >> +             if (!(dentry->d_flags & DCACHE_MANAGE_TRANSIT) &&
>> >> +                  (dentry->d_flags & DCACHE_NEED_AUTOMOUNT))
>> >> +                     __managed_dentry_set_transit(path->dentry);
>> >> +             spin_unlock(&dentry->d_lock);
>> >> +     }
>> >> +     //spin_unlock(&dcache_lock);
>> >
>> > In this case I think the dcache_lock needs to be deleted and the d_lock
>> > moved out of the if to protect the d_subdirs access.
>>
>> Right. If you follow the vfs-scale-working git branch series of
>> patches leading up to dcache_lock removal, it gives a pretty
>> good template of how to convert old dcache_lock using code
>> to new locking.
>>
>> Although you can also just look at locking in fs/dcache.c and
>> convert code from that.
>>
>> Any time you are dealing with just a *single* dentry, then
>> ->d_lock would be enough to replace dcache_lock (it
>> actually protects more than dcache_lock alone did).
>
> Does it make sense to leave the lock where it is and repeat the outer test
> after we've taken the lock?

I'll make the usual suggestion to make the locking simple, and
even avoiding all unlocked-load-then-recheck type of access,
unless there is a good reason to need it.

Many cases of ordering bugs I've found are due to these
seemingly simple and obvious optimisations.

It's up to you of course, is it worth having to think a little bit
harder about? Ian and yourself could probably answer that
better than me.
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-01-14 15:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13 21:53 [PATCH 00/18] Introduce automount support in the VFS [ver #4] David Howells
2011-01-13 21:54 ` [PATCH 01/18] Add a dentry op to handle automounting rather than abusing follow_link() " David Howells
2011-01-16  0:09   ` Al Viro
2011-01-16  1:17     ` Al Viro
2011-01-16 18:12     ` David Howells
2011-01-13 21:54 ` [PATCH 02/18] Add a dentry op to allow processes to be held during pathwalk transit " David Howells
2011-01-13 21:54 ` [PATCH 03/18] From: David Howells <dhowells@redhat.com> " David Howells
2011-01-13 21:54 ` [PATCH 04/18] AFS: Use d_automount() rather than abusing follow_link() " David Howells
2011-01-13 21:54 ` [PATCH 05/18] NFS: " David Howells
2011-01-13 21:54 ` [PATCH 06/18] CIFS: " David Howells
2011-01-13 21:54 ` [PATCH 07/18] Remove the automount through follow_link() kludge code from pathwalk " David Howells
2011-01-13 21:54 ` [PATCH 08/18] autofs4: Add d_automount() dentry operation " David Howells
2011-01-13 21:54 ` [PATCH 09/18] autofs4: Add d_manage() " David Howells
2011-01-14 13:51   ` Ian Kent
2011-01-14 14:37     ` Nick Piggin
2011-01-14 15:47       ` Nick Piggin
2011-01-14 15:35     ` David Howells
2011-01-14 15:46       ` Nick Piggin [this message]
2011-01-13 21:54 ` [PATCH 10/18] autofs4: Remove unused code " David Howells
2011-01-13 21:54 ` [PATCH 11/18] autofs4: Clean up inode operations " David Howells
2011-01-13 21:55 ` [PATCH 12/18] autofs4: Clean up dentry " David Howells
2011-01-13 21:55 ` [PATCH 13/18] autofs4: Clean up autofs4_free_ino() " David Howells
2011-01-14 16:03   ` Al Viro
2011-01-13 21:55 ` [PATCH 14/18] autofs4: Fix wait validation " David Howells
2011-01-13 21:55 ` [PATCH 15/18] autofs4: Add v4 pseudo direct mount support " David Howells
2011-01-13 21:55 ` [PATCH 16/18] autofs4: Bump version " David Howells
2011-01-13 21:55 ` [PATCH 17/18] Remove a further kludge from __do_follow_link() " David Howells
2011-01-13 21:55 ` [PATCH 18/18] Allow d_manage() to be used in RCU-walk mode " David Howells
2011-01-14  7:02 ` [PATCH 00/18] Introduce automount support in the VFS " Al Viro
2011-01-14  7:05   ` Al Viro
2011-01-14 11:20   ` David Howells
2011-01-14 11:43 ` David Howells
2011-01-14 15:46   ` Al Viro
2011-01-14 17:26   ` [PATCH 19/18] Unexport do_add_mount() and add in follow_automount(), not ->d_automount() David Howells
2011-01-14 17:43     ` Al Viro
2011-01-14 17:56       ` Al Viro
2011-01-14 18:06         ` Al Viro
2011-01-14 22:07           ` Nick Piggin
2011-01-15 13:30             ` Al Viro
2011-01-15 18:33               ` Nick Piggin
2011-01-16  0:24                 ` Al Viro
2011-01-16  1:21                   ` Nick Piggin
2011-01-15 18:46               ` Nick Piggin
2011-01-14 17:30   ` David Howells
2011-01-14 11:54 ` [PATCH 00/18] Introduce automount support in the VFS [ver #4] David Howells

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=AANLkTin0YuRx9gRXLLJKOu4BOXYxOMnWmSsRLxAzXzdo@mail.gmail.com \
    --to=npiggin@gmail.com \
    --cc=autofs@linux.kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=npiggin@kernel.dk \
    --cc=raven@themaw.net \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).