Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19205729rwd; Wed, 28 Jun 2023 06:31:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ50uFX/0BkS695FSK56GolSW7Y3eITC4u79Ys3u6GU7s7zKaB+lS94ENp6EH3h01HmwaY3w X-Received: by 2002:a05:6a20:8411:b0:103:b436:aef7 with SMTP id c17-20020a056a20841100b00103b436aef7mr2025837pzd.16.1687959076033; Wed, 28 Jun 2023 06:31:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687959076; cv=none; d=google.com; s=arc-20160816; b=DlEOyeBtmzUiSwRq1bbQgpK5KBYPKDrlW2jsfy2d3+fuI2Rz4QEwbSCgkHrrG2iO2B LjI/ijFtsjqEI0ZuUizc/7gXQNMqy+HXDqYnVnuIjLlvXxdEQiWgYWcre0Vl5j9k00Vr BkPsK/my5K6NPs5sNCjBr73PWPPX7juBoT2u/Y7rh+2HlTuiq1bHYPLUKDvxhTvBRoZP CAyg+Eq0dHkBCDOA22XzGVTVchFmxdRfuwl654FTs2i8KUOwWplZVYnU2df1aiGQipFn WNJqycSkcqcYKHm4CKFEwinN+JKzaHaOz83eLQ3IUQLLuJBEy5mES2rNUgU/w65TsPE7 Nobw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=0YtnuQL9fdTe91F8Upe9h0bbgcKnbi8/8KfSIz4Hbao=; fh=fHzCyx2lgDg5rzxkd+fn4L1zIOfYfCj3lN8BN24cVWY=; b=r+V7FGMDCvT8hMAkMhsZQVmJKYzQQr6yETzRmLChrsFA1EImS/K0W3WIgM6YgFXUCj WK54ZGFJwfEUZYNj7r2/TjKAhFSyeE6TkMZWAcnIjPpiKmdWUxbqrzscIUJNXPZ5kiGR n8LN9n5g2HpekjorZ8y71m+KJ4K2S9gSeLhlXStzsL0S6fvBXKLAktUlvM67JMi99XO0 IS4khmkQBFVKcciD75ZBFe4rLh1KFneFzEcMSkJyrRg8fbdUGkHTF7hb/oq2yNIWBoyf qmWVuW0aOCa0L+55R+JGax5vW3mFfzWd89Siax/B101vgFhzraDpP3XPHErrGI74LOyE PSlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g26-20020a63201a000000b005030925d31asi9149998pgg.203.2023.06.28.06.31.01; Wed, 28 Jun 2023 06:31:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231996AbjF1NYi (ORCPT + 99 others); Wed, 28 Jun 2023 09:24:38 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:21998 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbjF1NY2 (ORCPT ); Wed, 28 Jun 2023 09:24:28 -0400 Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Qrj0G0vmjzlW5m; Wed, 28 Jun 2023 21:21:34 +0800 (CST) Received: from huawei.com (10.175.127.227) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 28 Jun 2023 21:24:18 +0800 From: Baokun Li To: CC: , , , , , , , Subject: [PATCH v2 4/7] quota: add new helper dquot_active() Date: Wed, 28 Jun 2023 21:21:52 +0800 Message-ID: <20230628132155.1560425-5-libaokun1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230628132155.1560425-1-libaokun1@huawei.com> References: <20230628132155.1560425-1-libaokun1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500021.china.huawei.com (7.185.36.21) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Add new helper function dquot_active() to make the code more concise. Signed-off-by: Baokun Li --- fs/quota/dquot.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index b21f5e888482..09787e4f6a00 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -353,6 +353,11 @@ static void wait_on_dquot(struct dquot *dquot) mutex_unlock(&dquot->dq_lock); } +static inline int dquot_active(struct dquot *dquot) +{ + return test_bit(DQ_ACTIVE_B, &dquot->dq_flags); +} + static inline int dquot_dirty(struct dquot *dquot) { return test_bit(DQ_MOD_B, &dquot->dq_flags); @@ -368,14 +373,14 @@ int dquot_mark_dquot_dirty(struct dquot *dquot) { int ret = 1; - if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) + if (!dquot_active(dquot)) return 0; if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY) return test_and_set_bit(DQ_MOD_B, &dquot->dq_flags); /* If quota is dirty already, we don't have to acquire dq_list_lock */ - if (test_bit(DQ_MOD_B, &dquot->dq_flags)) + if (dquot_dirty(dquot)) return 1; spin_lock(&dq_list_lock); @@ -457,7 +462,7 @@ int dquot_acquire(struct dquot *dquot) smp_mb__before_atomic(); set_bit(DQ_READ_B, &dquot->dq_flags); /* Instantiate dquot if needed */ - if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { + if (!dquot_active(dquot) && !dquot->dq_off) { ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); /* Write the info if needed */ if (info_dirty(&dqopt->info[dquot->dq_id.type])) { @@ -499,7 +504,7 @@ int dquot_commit(struct dquot *dquot) goto out_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)) + if (dquot_active(dquot)) ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); else ret = -EIO; @@ -614,7 +619,7 @@ int dquot_scan_active(struct super_block *sb, spin_lock(&dq_list_lock); list_for_each_entry(dquot, &inuse_list, dq_inuse) { - if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) + if (!dquot_active(dquot)) continue; if (dquot->dq_sb != sb) continue; @@ -629,7 +634,7 @@ int dquot_scan_active(struct super_block *sb, * outstanding call and recheck the DQ_ACTIVE_B after that. */ wait_on_dquot(dquot); - if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { + if (dquot_active(dquot)) { ret = fn(dquot, priv); if (ret < 0) goto out; @@ -680,7 +685,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type) dquot = list_first_entry(&dirty, struct dquot, dq_dirty); - WARN_ON(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)); + WARN_ON(!dquot_active(dquot)); /* Now we have active dquot from which someone is * holding reference so we can safely just increase @@ -817,7 +822,7 @@ void dqput(struct dquot *dquot) dquot_write_dquot(dquot); goto we_slept; } - if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { + if (dquot_active(dquot)) { spin_unlock(&dq_list_lock); dquot->dq_sb->dq_op->release_dquot(dquot); goto we_slept; @@ -918,7 +923,7 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid) * already finished or it will be canceled due to dq_count > 1 test */ wait_on_dquot(dquot); /* Read the dquot / allocate space in quota file */ - if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { + if (!dquot_active(dquot)) { int err; err = sb->dq_op->acquire_dquot(dquot); -- 2.31.1