Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22114562rwd; Fri, 30 Jun 2023 04:11:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlE8Y4J/uhG48V+rhGdVNFeUF35jU9MeRGpT+CMiss0VdGIf6ligKXsnRBKA3MUm8ZYdPOF/ X-Received: by 2002:aa7:88d6:0:b0:668:8545:cbeb with SMTP id k22-20020aa788d6000000b006688545cbebmr3302794pff.15.1688123509318; Fri, 30 Jun 2023 04:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688123509; cv=none; d=google.com; s=arc-20160816; b=A+NX+tW/+psL5JBHny/akZS+gIdRWfdaDPDpVBh7iSxxnz5IWDveJZsDiT0EwoPa9Y ORpKjLP3Im5ErQUrZXmBLgsRmqeVuAokFTXGzF1FG7NZz61LiZ5o7ciHVg0nEMJY+v1C Rh2DHO7K4gOL1OAk5V+jGykOEgSYSnSTggB2+qMwEkpOOXkpFu0gt0x4ewOdeInfgdRu iRbLlSc0JaPRpUjR/pzhwmO4KY5nUECRe8R5T6mXvUN9CKZcPNrV5+V87JV2ApN296EO 8TBUfY9V5IEywDoAnpRMuqfhOfaN7zUZRvQcEseRBegduYdP2C2g4wSMCBZs5o4WwD8q pLiQ== 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=tKPqbJO0I6opH8kAIM8+Jag24SkzHZFwki6wRjrcvMM=; fh=fHzCyx2lgDg5rzxkd+fn4L1zIOfYfCj3lN8BN24cVWY=; b=dUzc+yNLThRC/UVqVzKixl0kmYo0178ceG5LNMyKvZ99hFu5MGMLapX3GkcDEjbkqG dKP4yEa+KwyI0ekJNnsLA6D8A4opk82KSH58L6f7fMST+xd/sgdzzftv2qECGgJe+W+5 s/E+/GJh+WdOTr///SHtkPXr6G9bk8cMwEXZYyimi6jvppdSArE/ZVUXa6fIb9ApY2/T N2zdv8IJGe0jGM6f0ZhkMp9oAIaS1pJogqni1chvjrOoIUQAwaBWdmcuKQBK8GlA7Xfs kYuL8fU68EjUps15FeJJivXusQ43Bg0sjmTjJvMen03nD9xCxXnfgj5c02LI0kMPSgAr S2rw== 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 s31-20020a056a00179f00b0067ff1a1ccbdsi5374868pfg.91.2023.06.30.04.11.33; Fri, 30 Jun 2023 04:11:49 -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 S232800AbjF3LK5 (ORCPT + 99 others); Fri, 30 Jun 2023 07:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232079AbjF3LKv (ORCPT ); Fri, 30 Jun 2023 07:10:51 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9877D10E5; Fri, 30 Jun 2023 04:10:49 -0700 (PDT) Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Qst046GPzz1HBpR; Fri, 30 Jun 2023 19:10:28 +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; Fri, 30 Jun 2023 19:10:47 +0800 From: Baokun Li To: CC: , , , , , , , Subject: [PATCH v3 3/5] quota: add new helper dquot_active() Date: Fri, 30 Jun 2023 19:08:20 +0800 Message-ID: <20230630110822.3881712-4-libaokun1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230630110822.3881712-1-libaokun1@huawei.com> References: <20230630110822.3881712-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: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500021.china.huawei.com (7.185.36.21) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 --- V2->V3: No change. 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 a08698d9859a..88aa747f4800 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -336,6 +336,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); @@ -351,14 +356,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); @@ -440,7 +445,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])) { @@ -482,7 +487,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; @@ -597,7 +602,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; @@ -612,7 +617,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; @@ -663,7 +668,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 @@ -800,7 +805,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; @@ -901,7 +906,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