From: Al Viro <viro@ZenIV.linux.org.uk>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Jeff Layton <jlayton@redhat.com>,
linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] nfs: don't use d_move in nfs_async_rename_done
Date: Mon, 18 Jul 2011 18:45:15 +0100 [thread overview]
Message-ID: <20110718174514.GD11013@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1311010514.23313.4.camel@lade.trondhjem.org>
On Mon, Jul 18, 2011 at 01:35:14PM -0400, Trond Myklebust wrote:
> On Mon, 2011-07-18 at 11:26 -0400, Jeff Layton wrote:
> > If the task that initiated the sillyrename ends up being killed by a
> > fatal signal, then it will eventually return back to userspace and end
> > up releasing the i_mutex. d_move however needs to be done while holding
> > the i_mutex.
>
> Umm... Where is this requirement documented? I thought the rename_lock
> was there to protect against lookup races etc with d_move.
It protects lookup against d_move(). It does *NOT* protect the i_mutex
locking scheme from deadlocks a-sodding-plenty and it does not protect
->d_parent/->d_name accesses in directory methods (->i_mutex does). The
latter is not a big deal, but the former is.
> Besides, NFS already has
> nfs_block_sillyrename()/nfs_unblock_sillyrename() to provide further
> exclusion between dentry lookups and revalidations and the silly-unlink
> code.
It's broken. We are dealing with more than just NFS data structures.
Don't change ->d_parent unless you hold ->i_mutex on parent(s) involved
and if they are different you need ->s_vfs_rename_mutex as well. See
lock_rename() in fs/namei.c and Documentation/filesystems/directory-locking.
Moreover, I would be very sceptical about the code trying to grap ->i_mutex
on ->d_parent of preexisting dentry, unless you have very good reasons to
be sure that it couldn't be moved around in the meanwhile.
d_move() in async rename is really broken...
prev parent reply other threads:[~2011-07-18 17:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-18 15:26 [PATCH] nfs: don't use d_move in nfs_async_rename_done Jeff Layton
2011-07-18 17:35 ` Trond Myklebust
2011-07-18 17:45 ` Al Viro [this message]
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=20110718174514.GD11013@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=Trond.Myklebust@netapp.com \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.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;
as well as URLs for NNTP newsgroup(s).