From: "J. Bruce Fields" <bfields@fieldses.org>
To: "J. Bruce Fields" <bfields@redhat.com>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>,
linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
samba-technical@lists.samba.org,
Christoph Hellwig <hch@infradead.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH 4/6] leases: break read leases on rename
Date: Fri, 23 Sep 2011 14:55:46 -0400 [thread overview]
Message-ID: <20110923185546.GA7389@fieldses.org> (raw)
In-Reply-To: <20110923165510.GA807@pad.fieldses.org>
On Fri, Sep 23, 2011 at 12:55:13PM -0400, J. Bruce Fields wrote:
> On Thu, Sep 22, 2011 at 01:17:49PM -0400, Mimi Zohar wrote:
> > On Wed, 2011-09-21 at 10:58 -0400, J. Bruce Fields wrote:
> > > To rely on the i_mutex for exclusion between setlease and rename, we
> > > need rename to take the i_mutex on the source as well as on any possible
> > > target.
> > >
> > > I suspect this is deadlock-free, but I need to think this proof through
> > > again. And I'm not sure what to do about lockdep.
> >
> > Not sure that I will be of any help, but how about posting the lockdep
> > messages?
>
> Sure, appended below, but it's not particularly surprising--we're taking
> i_mutex's on four different objects (both parents, source, and target if
> any) where before there were three.
>
> I suppose the solution is another i_mutex lock class, used only on the
> lock of the source inode?
That'd be something like this. (Works for me, anyway.) I'll fold it
into the previous patch.
--b.
diff --git a/fs/namei.c b/fs/namei.c
index f6de42d..06a8d95 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3069,7 +3069,7 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
return error;
dget(new_dentry);
- mutex_lock(&source->i_mutex);
+ mutex_lock_nested(&source->i_mutex, I_MUTEX_RENAME_SOURCE);
error = break_lease(source, O_WRONLY);
if (error)
goto out_unlock_source;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 76460ed..74f4979 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -839,10 +839,12 @@ static inline int inode_unhashed(struct inode *inode)
* 0: the object of the current VFS operation
* 1: parent
* 2: child/target
- * 3: quota file
+ * 3: xattr
+ * 4: quota file
+ * 5: the file being renamed (used only in rename of a non-directory)
*
* The locking order between these classes is
- * parent -> child -> normal -> xattr -> quota
+ * parent -> child -> rename_source -> normal -> xattr -> quota
*/
enum inode_i_mutex_lock_class
{
@@ -850,7 +852,8 @@ enum inode_i_mutex_lock_class
I_MUTEX_PARENT,
I_MUTEX_CHILD,
I_MUTEX_XATTR,
- I_MUTEX_QUOTA
+ I_MUTEX_QUOTA,
+ I_MUTEX_RENAME_SOURCE
};
/*
WARNING: multiple messages have this Message-ID (diff)
From: "J. Bruce Fields" <bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
To: "J. Bruce Fields" <bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Mimi Zohar
<zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.org,
Christoph Hellwig <hch-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
Subject: Re: [PATCH 4/6] leases: break read leases on rename
Date: Fri, 23 Sep 2011 14:55:46 -0400 [thread overview]
Message-ID: <20110923185546.GA7389@fieldses.org> (raw)
In-Reply-To: <20110923165510.GA807-spRCxval1Z7TsXDwO4sDpg@public.gmane.org>
On Fri, Sep 23, 2011 at 12:55:13PM -0400, J. Bruce Fields wrote:
> On Thu, Sep 22, 2011 at 01:17:49PM -0400, Mimi Zohar wrote:
> > On Wed, 2011-09-21 at 10:58 -0400, J. Bruce Fields wrote:
> > > To rely on the i_mutex for exclusion between setlease and rename, we
> > > need rename to take the i_mutex on the source as well as on any possible
> > > target.
> > >
> > > I suspect this is deadlock-free, but I need to think this proof through
> > > again. And I'm not sure what to do about lockdep.
> >
> > Not sure that I will be of any help, but how about posting the lockdep
> > messages?
>
> Sure, appended below, but it's not particularly surprising--we're taking
> i_mutex's on four different objects (both parents, source, and target if
> any) where before there were three.
>
> I suppose the solution is another i_mutex lock class, used only on the
> lock of the source inode?
That'd be something like this. (Works for me, anyway.) I'll fold it
into the previous patch.
--b.
diff --git a/fs/namei.c b/fs/namei.c
index f6de42d..06a8d95 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3069,7 +3069,7 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
return error;
dget(new_dentry);
- mutex_lock(&source->i_mutex);
+ mutex_lock_nested(&source->i_mutex, I_MUTEX_RENAME_SOURCE);
error = break_lease(source, O_WRONLY);
if (error)
goto out_unlock_source;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 76460ed..74f4979 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -839,10 +839,12 @@ static inline int inode_unhashed(struct inode *inode)
* 0: the object of the current VFS operation
* 1: parent
* 2: child/target
- * 3: quota file
+ * 3: xattr
+ * 4: quota file
+ * 5: the file being renamed (used only in rename of a non-directory)
*
* The locking order between these classes is
- * parent -> child -> normal -> xattr -> quota
+ * parent -> child -> rename_source -> normal -> xattr -> quota
*/
enum inode_i_mutex_lock_class
{
@@ -850,7 +852,8 @@ enum inode_i_mutex_lock_class
I_MUTEX_PARENT,
I_MUTEX_CHILD,
I_MUTEX_XATTR,
- I_MUTEX_QUOTA
+ I_MUTEX_QUOTA,
+ I_MUTEX_RENAME_SOURCE
};
/*
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-09-23 18:55 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-21 14:58 breaking leases on metadata changes J. Bruce Fields
2011-09-21 14:58 ` [PATCH 1/6] leases: split up generic_setlease into lock/unlock cases J. Bruce Fields
2011-09-21 14:58 ` J. Bruce Fields
2011-09-22 17:16 ` Mimi Zohar
2011-09-22 17:16 ` Mimi Zohar
2011-09-23 18:57 ` J. Bruce Fields
2011-09-23 18:57 ` J. Bruce Fields
2011-09-21 14:58 ` [PATCH 2/6] leases: fix write-open/read-lease race J. Bruce Fields
2011-09-21 15:01 ` J. Bruce Fields
2011-09-22 17:17 ` Mimi Zohar
2011-09-22 17:17 ` Mimi Zohar
2011-10-10 21:59 ` J. Bruce Fields
2011-10-10 21:59 ` J. Bruce Fields
2011-10-11 6:19 ` Need information about the net ads user command Pankaj Baranwal
2011-10-11 6:19 ` Pankaj Baranwal
2011-10-28 8:46 ` [PATCH 2/6] leases: fix write-open/read-lease race J. Bruce Fields
2011-10-28 8:46 ` J. Bruce Fields
2011-09-21 14:58 ` [PATCH 3/6] leases: break read leases on unlink J. Bruce Fields
2011-09-21 15:02 ` Christoph Hellwig
2011-09-21 15:02 ` Christoph Hellwig
2011-09-21 17:41 ` J. Bruce Fields
2011-09-21 17:41 ` J. Bruce Fields
2011-09-21 14:58 ` [PATCH 4/6] leases: break read leases on rename J. Bruce Fields
2011-09-22 17:17 ` Mimi Zohar
2011-09-22 17:17 ` Mimi Zohar
2011-09-23 16:55 ` J. Bruce Fields
2011-09-23 16:55 ` J. Bruce Fields
2011-09-23 18:55 ` J. Bruce Fields [this message]
2011-09-23 18:55 ` J. Bruce Fields
2011-09-23 19:58 ` Mimi Zohar
2011-09-23 20:13 ` J. Bruce Fields
2011-09-23 20:13 ` J. Bruce Fields
2011-09-21 14:58 ` [PATCH 5/6] leases: break leases on any attribute modification J. Bruce Fields
2011-09-21 14:58 ` J. Bruce Fields
2011-09-21 15:35 ` J. Bruce Fields
2011-09-21 14:58 ` [PATCH 6/6] leases: break read leases on link J. Bruce Fields
2011-09-24 18:36 ` breaking leases on metadata changes Stefan (metze) Metzmacher
2011-09-24 18:36 ` Stefan (metze) Metzmacher
2011-09-26 14:10 ` J. Bruce Fields
2011-09-26 16:16 ` J. Bruce Fields
2011-09-26 16:16 ` J. Bruce Fields
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=20110923185546.GA7389@fieldses.org \
--to=bfields@fieldses.org \
--cc=bfields@redhat.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zohar@linux.vnet.ibm.com \
/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.