[PATCH 15/19] quota: remove dq_state_lock

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

 



dqget() is the only reader which use dq_state_lock, in fact locking is not
necessery for all readers. All writers are already serialized by
dqonoff_mutex. We can safely remove dq_state_lock.

Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
---
 fs/quota/dquot.c |   19 ++-----------------
 1 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 0d755ef..9779800 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -87,13 +87,10 @@
  * dq_lock protects dquot->dq_dqb and also guards consistency of
  * dquot->dq_dqb with inode->i_blocks, i_bytes.
  * i_blocks and i_bytes updates itself are guarded by i_lock acquired directly
- * in inode_add_bytes() and inode_sub_bytes(). dq_state_lock protects
- * modifications of quota state (on quotaon and quotaoff) and readers who care
- * about latest values take it as well.
+ * in inode_add_bytes() and inode_sub_bytes().
  *
  * The spinlock ordering is hence:
- *   dq_data_lock > dq_lock > dq_list_lock > i_lock,
- *   dq_list_lock > dq_state_lock
+ *   dq_data_lock > dq_lock > dq_list_lock > i_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
@@ -2025,7 +2022,6 @@ static int alloc_quota_info(struct quota_ctl_info *dqctl) {
 		return err;
 
 	mutex_init(&dqopt->dqio_mutex);
-	spin_lock_init(&dqopt->dq_state_lock);
 	spin_lock_init(&dqopt->dq_data_lock);
 	spin_lock_init(&dqopt->dq_list_lock);
 	INIT_LIST_HEAD(&dqopt->dq_inuse_list);
@@ -2087,24 +2083,19 @@ int dquot_disable(struct super_block *sb, int type, unsigned int flags)
 			continue;
 
 		if (flags & DQUOT_SUSPENDED) {
-			spin_lock(&dqopt->dq_state_lock);
 			qctl->flags |=
 				dquot_state_flag(DQUOT_SUSPENDED, cnt);
-			spin_unlock(&dqopt->dq_state_lock);
 		} else {
-			spin_lock(&dqopt->dq_state_lock);
 			qctl->flags &= ~dquot_state_flag(flags, cnt);
 			/* Turning off suspended quotas? */
 			if (!sb_has_quota_loaded(sb, cnt) &&
 			    sb_has_quota_suspended(sb, cnt)) {
 				qctl->flags &=	~dquot_state_flag(
 							DQUOT_SUSPENDED, cnt);
-				spin_unlock(&dqopt->dq_state_lock);
 				iput(dqopt->files[cnt]);
 				dqopt->files[cnt] = NULL;
 				continue;
 			}
-			spin_unlock(&dqopt->dq_state_lock);
 		}
 
 		/* We still have to keep quota loaded? */
@@ -2301,9 +2292,7 @@ static int vfs_load_quota_inode(struct inode *inode, int type, int format_id,
 		goto out_file_init;
 	}
 	mutex_unlock(&dqopt->dqio_mutex);
-	spin_lock(&dqopt->dq_state_lock);
 	dqctl(sb)->flags |= dquot_state_flag(flags, type);
-	spin_unlock(&dqopt->dq_state_lock);
 
 	add_dquot_ref(sb, type);
 	mutex_unlock(&dqctl(sb)->dqonoff_mutex);
@@ -2348,12 +2337,10 @@ int dquot_resume(struct super_block *sb, int type)
 		}
 		inode = qctl->dq_opt->files[cnt];
 		qctl->dq_opt->files[cnt] = NULL;
-		spin_lock(&dqopts(sb)->dq_state_lock);
 		flags = qctl->flags & dquot_state_flag(DQUOT_USAGE_ENABLED |
 							DQUOT_LIMITS_ENABLED,
 							cnt);
 		qctl->flags &= ~dquot_state_flag(DQUOT_STATE_FLAGS, cnt);
-		spin_unlock(&dqopts(sb)->dq_state_lock);
 		mutex_unlock(&qctl->dqonoff_mutex);
 
 		flags = dquot_generic_flag(flags, cnt);
@@ -2432,9 +2419,7 @@ int dquot_enable(struct inode *inode, int type, int format_id,
 			ret = -EBUSY;
 			goto out_lock;
 		}
-		spin_lock(&dqopts(sb)->dq_state_lock);
 		qctl->flags |= dquot_state_flag(flags, type);
-		spin_unlock(&dqopts(sb)->dq_state_lock);
 out_lock:
 		mutex_unlock(&qctl->dqonoff_mutex);
 		return ret;
-- 
1.6.5.2

--
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