From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: jack@suse.cz, hch@infradead.org,
Dmitry Monakhov <dmonakhov@gmail.com>,
Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 08/19] quota: remove global dq_list_lock
Date: Fri, 22 Oct 2010 21:34:53 +0400 [thread overview]
Message-ID: <1287768904-27810-9-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1287768904-27810-1-git-send-email-dmonakhov@openvz.org>
From: Dmitry Monakhov <dmonakhov@gmail.com>
dq_list_lock is no longer responsible for any synchronization,
and we may remove it now.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/quota/dquot.c | 37 ++-----------------------------------
1 files changed, 2 insertions(+), 35 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 822d7ad..2d08996 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -90,8 +90,8 @@
* about latest values take it as well.
*
* The spinlock ordering is hence: dq_data_lock > dq_list_lock > i_lock,
- * dq_list_lock > sb->s_dquot->dq_state_lock
- * dq_list_lock > sb->s_dquot->dq_list_lock
+ * dq_list_lock > dq_state_lock
+ * dq_list_lock > dq_list_lock
*
* Note that some things (eg. sb pointer, type, id) doesn't change during
* the life of the dquot structure and so needn't to be protected by a lock
@@ -127,7 +127,6 @@
* i_mutex on quota files is special (it's below dqio_mutex)
*/
-static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_list_lock);
static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_fmt_lock);
__cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_data_lock);
EXPORT_SYMBOL(dq_data_lock);
@@ -346,7 +345,6 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
if (test_bit(DQ_MOD_B, &dquot->dq_flags))
return 1;
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) {
list_add(&dquot->dq_dirty,
@@ -354,7 +352,6 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
ret = 0;
}
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
return ret;
}
EXPORT_SYMBOL(dquot_mark_dquot_dirty);
@@ -446,15 +443,12 @@ int dquot_commit(struct dquot *dquot)
struct quota_info *dqopt = sb_dqopts(dquot);
mutex_lock(&dqopt->dqio_mutex);
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
if (!clear_dquot_dirty(dquot)) {
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
goto out_sem;
}
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
/* Inactive dquot can be only if there was error during read/init
* => we have better not writing it */
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
@@ -526,7 +520,6 @@ static void invalidate_dquots(struct super_block *sb, int type)
struct quota_info *dqopt = dqopts(sb);
restart:
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
list_for_each_entry_safe(dquot, tmp, &dqopt->dq_inuse_list, dq_inuse) {
if (dquot->dq_sb != sb)
@@ -541,7 +534,6 @@ restart:
prepare_to_wait(&dquot->dq_wait_unused, &wait,
TASK_UNINTERRUPTIBLE);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
/* Once dqput() wakes us up, we know it's time to free
* the dquot.
* IMPORTANT: we rely on the fact that there is always
@@ -568,7 +560,6 @@ restart:
do_destroy_dquot(dquot);
}
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
}
/* Call callback for every active dquot on given filesystem */
@@ -582,7 +573,6 @@ int dquot_scan_active(struct super_block *sb,
mutex_lock(&dqctl(sb)->dqonoff_mutex);
dqopt = dqopts(sb);
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
list_for_each_entry(dquot, &dqopt->dq_inuse_list, dq_inuse) {
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
@@ -592,20 +582,17 @@ int dquot_scan_active(struct super_block *sb,
/* Now we have active dquot so we can just increase use count */
atomic_inc(&dquot->dq_count);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
dqstats_inc(DQST_LOOKUPS);
dqput(old_dquot);
old_dquot = dquot;
ret = fn(dquot, priv);
if (ret < 0)
goto out;
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
/* We are safe to continue now because our dquot could not
* be moved out of the inuse list while we hold the reference */
}
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
out:
dqput(old_dquot);
mutex_unlock(&dqctl(sb)->dqonoff_mutex);
@@ -627,7 +614,6 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
continue;
if (!sb_has_quota_active(sb, cnt))
continue;
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
dirty = &dqopt->info[cnt].dqi_dirty_list;
while (!list_empty(dirty)) {
@@ -643,15 +629,12 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
* use count */
atomic_inc(&dquot->dq_count);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
dqstats_inc(DQST_LOOKUPS);
dqctl(sb)->dq_op->write_dquot(dquot);
dqput(dquot);
spin_lock(&dqopt->dq_list_lock);
- spin_lock(&dq_list_lock);
}
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
}
for (cnt = 0; cnt < MAXQUOTAS; cnt++)
@@ -731,9 +714,7 @@ static void prune_dqcache(int count)
static int shrink_dqcache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
{
if (nr) {
- spin_lock(&dq_list_lock);
prune_dqcache(nr);
- spin_unlock(&dq_list_lock);
}
return ((unsigned)
percpu_counter_read_positive(&dqstats.counter[DQST_FREE_DQUOTS])
@@ -766,7 +747,6 @@ void dqput(struct dquot *dquot)
dqopt = sb_dqopts(dquot);
dqstats_inc(DQST_DROPS);
we_slept:
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
if (atomic_read(&dquot->dq_count) > 1) {
/* We have more than one user... nothing to do */
@@ -776,13 +756,11 @@ we_slept:
atomic_read(&dquot->dq_count) == 1)
wake_up(&dquot->dq_wait_unused);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
return;
}
/* Need to release dquot? */
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && dquot_dirty(dquot)) {
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
/* Commit dquot before releasing */
ret = dqctl(dquot->dq_sb)->dq_op->write_dquot(dquot);
if (ret < 0) {
@@ -793,11 +771,9 @@ we_slept:
* We clear dirty bit anyway, so that we avoid
* infinite loop here
*/
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
clear_dquot_dirty(dquot);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
}
goto we_slept;
}
@@ -805,7 +781,6 @@ we_slept:
clear_dquot_dirty(dquot);
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
dqctl(dquot->dq_sb)->dq_op->release_dquot(dquot);
goto we_slept;
}
@@ -816,7 +791,6 @@ we_slept:
#endif
put_dquot_last(dquot);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
}
EXPORT_SYMBOL(dqput);
@@ -863,13 +837,11 @@ struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
if (!sb_has_quota_active(sb, type))
return NULL;
we_slept:
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
spin_lock(&dqopt->dq_state_lock);
if (!sb_has_quota_active(sb, type)) {
spin_unlock(&dqopt->dq_state_lock);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
goto out;
}
spin_unlock(&dqopt->dq_state_lock);
@@ -878,7 +850,6 @@ we_slept:
if (!dquot) {
if (!empty) {
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
empty = get_empty_dquot(sb, type);
if (!empty)
schedule(); /* Try to wait for a moment... */
@@ -892,14 +863,12 @@ we_slept:
/* hash it first so it can be found */
insert_dquot_hash(dquot);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
dqstats_inc(DQST_LOOKUPS);
} else {
if (!atomic_read(&dquot->dq_count))
remove_free_dquot(dquot);
atomic_inc(&dquot->dq_count);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
dqstats_inc(DQST_CACHE_HITS);
dqstats_inc(DQST_LOOKUPS);
}
@@ -1015,13 +984,11 @@ static int remove_inode_dquot_ref(struct inode *inode, int type,
"dq_count %d to dispose list",
atomic_read(&dquot->dq_count));
#endif
- spin_lock(&dq_list_lock);
spin_lock(&dqopt->dq_list_lock);
/* As dquot must have currently users it can't be on
* the free list... */
list_add(&dquot->dq_free, tofree_head);
spin_unlock(&dqopt->dq_list_lock);
- spin_unlock(&dq_list_lock);
return 1;
}
else
--
1.6.5.2
next prev parent reply other threads:[~2010-10-22 17:35 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 17:34 [PATCH 00/19] quota: RFC SMP improvements for generic quota V2 Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 01/19] quota: protect getfmt call with dqonoff_mutex lock Dmitry Monakhov
2010-10-28 14:27 ` Christoph Hellwig
2010-10-22 17:34 ` [PATCH 02/19] quota: Wrap common expression to helper function Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 03/19] quota: mode quota internals from sb to quota_info Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 04/19] quota: Convert dq_state_lock to per-sb dq_state_lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 05/19] quota: add quota format lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 06/19] quota: make dquot lists per-sb Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 07/19] quota: make per-sb hash array Dmitry Monakhov
2010-10-27 19:31 ` Al Viro
2010-10-28 10:58 ` Dmitry
2010-10-22 17:34 ` Dmitry Monakhov [this message]
2010-10-22 17:34 ` [PATCH 09/19] quota: rename dq_lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 10/19] quota: make per-sb dq_data_lock Dmitry Monakhov
2010-10-26 17:38 ` Dmitry
2010-10-22 17:34 ` [PATCH 11/19] quota: protect dquot mem info with object's lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 12/19] quota: drop dq_data_lock where possible Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 13/19] quota: relax dq_data_lock dq_lock locking consistency Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 14/19] quota: protect dqget() from parallels quotaoff via RCU Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 15/19] quota: remove dq_state_lock Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 16/19] fs: add unlocked helpers Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 17/19] quota: Some stylistic cleanup for dquot interface Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 18/19] quota: remove dqptr_sem Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 19/19] quota: redesign dquot reference counting Dmitry Monakhov
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=1287768904-27810-9-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=dmonakhov@gmail.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@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).