[RHEL7,COMMIT] ms/quota: Move locking into clear_dquot_dirty()

Submitted by Konstantin Khorenko on Jan. 30, 2020, 7:26 p.m.

Details

Message ID 202001301926.00UJQoJc015176@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Jan. 30, 2020, 7:26 p.m.
The commit is pushed to "branch-rh7-3.10.0-1062.7.1.vz7.130.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.7.1.vz7.130.13
------>
commit 78282dafd5f24769170cc8649c1e2049736aa270
Author: Jan Kara <jack@suse.cz>
Date:   Thu Jan 30 22:26:49 2020 +0300

    ms/quota: Move locking into clear_dquot_dirty()
    
    Move locking of dq_list_lock into clear_dquot_dirty(). It makes the
    function more self-contained and will simplify our life later.
    
    Reviewed-by: Andreas Dilger <adilger@dilger.ca>
    Signed-off-by: Jan Kara <jack@suse.cz>
    
    https://jira.sw.ru/browse/PSBM-101043
    (cherry picked from commit 1e0b7cb062f227439a1d8e7921e85c8df52adc41)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 fs/quota/dquot.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index bc5ff11f68b8c..989dce79fa12b 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -384,12 +384,15 @@  static inline void dqput_all(struct dquot **dquot)
 		dqput(dquot[cnt]);
 }
 
-/* This function needs dq_list_lock */
 static inline int clear_dquot_dirty(struct dquot *dquot)
 {
-	if (!test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags))
+	spin_lock(&dq_list_lock);
+	if (!test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags)) {
+		spin_unlock(&dq_list_lock);
 		return 0;
+	}
 	list_del_init(&dquot->dq_dirty);
+	spin_unlock(&dq_list_lock);
 	return 1;
 }
 
@@ -447,12 +450,8 @@  int dquot_commit(struct dquot *dquot)
 	struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
 
 	mutex_lock(&dqopt->dqio_mutex);
-	spin_lock(&dq_list_lock);
-	if (!clear_dquot_dirty(dquot)) {
-		spin_unlock(&dq_list_lock);
+	if (!clear_dquot_dirty(dquot))
 		goto out_sem;
-	}
-	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))
@@ -772,9 +771,7 @@  void dqput(struct dquot *dquot)
 			 * We clear dirty bit anyway, so that we avoid
 			 * infinite loop here
 			 */
-			spin_lock(&dq_list_lock);
 			clear_dquot_dirty(dquot);
-			spin_unlock(&dq_list_lock);
 		}
 		goto we_slept;
 	}