[PATCH 06/11] quota: remove global dq_list_lock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



dq_list_lock is no longer responsible for any synchronization,
and we may remove it now.

Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxx>
---
 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 e93b323..7401ce8 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 = dq_opt(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 = sb_dqopt(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 */
@@ -581,7 +572,6 @@ int dquot_scan_active(struct super_block *sb,
 	int ret = 0;
 
 	mutex_lock(&dqopt->dqonoff_mutex);
-	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))
@@ -591,20 +581,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(&dqopt->dqonoff_mutex);
@@ -625,7 +612,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)) {
@@ -641,16 +627,13 @@ 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);
 			sb->dq_op->write_dquot(dquot);
 			dqput(dquot);
-			spin_lock(&dq_list_lock);
 			spin_lock(&dqopt->dq_list_lock);
 
 		}
 		spin_unlock(&dqopt->dq_list_lock);
-		spin_unlock(&dq_list_lock);
 	}
 
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++)
@@ -723,9 +706,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])
@@ -758,7 +739,6 @@ void dqput(struct dquot *dquot)
 	dqopt = dq_opt(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 */
@@ -768,13 +748,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 = dquot->dq_sb->dq_op->write_dquot(dquot);
 		if (ret < 0) {
@@ -785,11 +763,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;
 	}
@@ -797,7 +773,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);
 		dquot->dq_sb->dq_op->release_dquot(dquot);
 		goto we_slept;
 	}
@@ -808,7 +783,6 @@ we_slept:
 #endif
 	put_dquot_last(dquot);
 	spin_unlock(&dqopt->dq_list_lock);
-	spin_unlock(&dq_list_lock);
 }
 EXPORT_SYMBOL(dqput);
 
@@ -855,13 +829,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(&sb_dqopt(sb)->dq_state_lock);
@@ -870,7 +842,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... */
@@ -884,14 +855,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);
 	}
@@ -1007,13 +976,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.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux