Return-Path: Received: from mx2.suse.de ([195.135.220.15]:37563 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752227AbdHPPlh (ORCPT ); Wed, 16 Aug 2017 11:41:37 -0400 From: Jan Kara To: Cc: Wang Shilong , Jan Kara Subject: [PATCH 11/27] quota: Push dqio_sem down to ->release_dqblk() Date: Wed, 16 Aug 2017 17:41:11 +0200 Message-Id: <20170816154127.7048-12-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: Push down acquisition of dqio_sem into ->release_dqblk() callback. It will allow quota formats to decide whether they need it or not. Signed-off-by: Jan Kara --- fs/quota/dquot.c | 4 ++-- fs/quota/quota_v2.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 562f5978488f..3b3c7f094ff8 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -478,19 +478,19 @@ int dquot_release(struct dquot *dquot) /* Check whether we are not racing with some other dqget() */ if (atomic_read(&dquot->dq_count) > 1) goto out_dqlock; - down_write(&dqopt->dqio_sem); if (dqopt->ops[dquot->dq_id.type]->release_dqblk) { ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot); /* Write the info */ if (info_dirty(&dqopt->info[dquot->dq_id.type])) { + down_write(&dqopt->dqio_sem); ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info( dquot->dq_sb, dquot->dq_id.type); + up_write(&dqopt->dqio_sem); } if (ret >= 0) ret = ret2; } clear_bit(DQ_ACTIVE_B, &dquot->dq_flags); - up_write(&dqopt->dqio_sem); out_dqlock: mutex_unlock(&dquot->dq_lock); return ret; diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c index 7a05b80f3b8c..8f54b159e423 100644 --- a/fs/quota/quota_v2.c +++ b/fs/quota/quota_v2.c @@ -322,7 +322,14 @@ static int v2_write_dquot(struct dquot *dquot) static int v2_release_dquot(struct dquot *dquot) { - return qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot); + struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); + int ret; + + down_write(&dqopt->dqio_sem); + ret = qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot); + up_write(&dqopt->dqio_sem); + + return ret; } static int v2_free_file_info(struct super_block *sb, int type) -- 2.12.3