From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
bfields@fieldses.org, Al Viro <viro@ZenIV.linux.org.uk>,
Jan Kara <jack@suse.cz>
Subject: [PATCH 6/6] quota: Get rid of nested I_MUTEX_QUOTA locking subclass
Date: Wed, 25 Apr 2012 22:57:47 +0200 [thread overview]
Message-ID: <1335387467-4928-7-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1335387467-4928-1-git-send-email-jack@suse.cz>
So far i_mutex was ranking above dqonoff_mutex and i_mutex on quota files
was special and ranking below dqonoff_mutex (and several other locks).
However there's no real need for i_mutex on quota files to be special.
IO on quota files is serialized by dqio_mutex anyway so we don't need to
take i_mutex when writing to quota files. Other places where we take i_mutex
on quota file can accomodate standard i_mutex lock ranking, we only need
to change the lock ranking to be dqonoff_mutex > i_mutex which is a matter
of changing documentation because there's no place which would enforce
ordering in the other direction.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/quota/dquot.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 1b7e0fc..d4ff981 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -116,15 +116,15 @@
* spinlock to internal buffers before writing.
*
* Lock ordering (including related VFS locks) is the following:
- * i_mutex > dqonoff_sem > journal_lock > dqptr_sem > dquot->dq_lock >
+ * dqonoff_mutex > i_mutex > journal_lock > dqptr_sem > dquot->dq_lock >
* dqio_mutex
+ * dqonoff_mutex > i_mutex comes from dquot_quota_sync, dquot_enable, etc.
* The lock ordering of dqptr_sem imposed by quota code is only dqonoff_sem >
* dqptr_sem. But filesystem has to count with the fact that functions such as
* dquot_alloc_space() acquire dqptr_sem and they usually have to be called
* from inside a transaction to keep filesystem consistency after a crash. Also
* filesystems usually want to do some IO on dquot from ->mark_dirty which is
* called with dqptr_sem held.
- * i_mutex on quota files is special (it's below dqio_mutex)
*/
static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_list_lock);
@@ -658,8 +658,7 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
continue;
if (!sb_has_quota_active(sb, cnt))
continue;
- mutex_lock_nested(&dqopt->files[cnt]->i_mutex,
- I_MUTEX_QUOTA);
+ mutex_lock(&dqopt->files[cnt]->i_mutex);
truncate_inode_pages(&dqopt->files[cnt]->i_data, 0);
mutex_unlock(&dqopt->files[cnt]->i_mutex);
}
@@ -2037,8 +2036,7 @@ int dquot_disable(struct super_block *sb, int type, unsigned int flags)
/* If quota was reenabled in the meantime, we have
* nothing to do */
if (!sb_has_quota_loaded(sb, cnt)) {
- mutex_lock_nested(&toputinode[cnt]->i_mutex,
- I_MUTEX_QUOTA);
+ mutex_lock(&toputinode[cnt]->i_mutex);
toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
S_NOATIME | S_NOQUOTA);
truncate_inode_pages(&toputinode[cnt]->i_data,
@@ -2133,7 +2131,7 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
/* We don't want quota and atime on quota files (deadlocks
* possible) Also nobody should write to the file - we use
* special IO operations which ignore the immutable bit. */
- mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
+ mutex_lock(&inode->i_mutex);
oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE |
S_NOQUOTA);
inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE;
@@ -2180,7 +2178,7 @@ out_file_init:
iput(inode);
out_lock:
if (oldflags != -1) {
- mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
+ mutex_lock(&inode->i_mutex);
/* Set the flags back (in the case of accidental quotaon()
* on a wrong file we don't want to mess up the flags) */
inode->i_flags &= ~(S_NOATIME | S_NOQUOTA | S_IMMUTABLE);
--
1.7.1
next prev parent reply other threads:[~2012-04-25 20:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-25 20:57 [PATCH 0/6] Get rid of I_MUTEX_QUOTA use Jan Kara
2012-04-25 20:57 ` [PATCH 1/6] ext3: Remove i_mutex use from ext3_quota_write() Jan Kara
2012-04-25 20:57 ` [PATCH 2/6] ext4: Remove i_mutex use from ext4_quota_write() Jan Kara
2012-04-25 20:57 ` [PATCH 3/6] reiserfs: Remove i_mutex use from reiserfs_quota_write() Jan Kara
2012-04-25 20:57 ` [PATCH 4/6] ext2: Remove i_mutex use from ext2_quota_write() Jan Kara
2012-04-25 20:57 ` [PATCH 5/6] quota: Use precomputed value of sb_dqopt in dquot_quota_sync Jan Kara
2012-04-25 20:57 ` Jan Kara [this message]
2012-04-25 21:25 ` [PATCH 0/6] Get rid of I_MUTEX_QUOTA use J. Bruce Fields
2012-04-26 13:26 ` Jan Kara
2012-04-27 13:47 ` J. Bruce Fields
2012-04-30 13:54 ` Jan Kara
2012-05-09 21:34 ` 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=1335387467-4928-7-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=bfields@fieldses.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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).