Return-Path: Received: from mx2.suse.de ([195.135.220.15]:37576 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752274AbdHPPll (ORCPT ); Wed, 16 Aug 2017 11:41:41 -0400 From: Jan Kara To: Cc: Wang Shilong , Jan Kara Subject: [PATCH 19/27] quota: Move locking into clear_dquot_dirty() Date: Wed, 16 Aug 2017 17:41:19 +0200 Message-Id: <20170816154127.7048-20-jack@suse.cz> In-Reply-To: <20170816154127.7048-1-jack@suse.cz> References: <20170816154127.7048-1-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Move locking of dq_list_lock into clear_dquot_dirty(). It makes the function more self-contained and will simplify our life later. Signed-off-by: Jan Kara --- fs/quota/dquot.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 67f154231072..4a407f30922d 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -375,12 +375,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; } @@ -445,12 +448,8 @@ int dquot_commit(struct dquot *dquot) struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); mutex_lock(&dquot->dq_lock); - spin_lock(&dq_list_lock); - if (!clear_dquot_dirty(dquot)) { - spin_unlock(&dq_list_lock); + if (!clear_dquot_dirty(dquot)) goto out_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)) @@ -766,9 +765,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; } -- 2.12.3