Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22114382rwd; Fri, 30 Jun 2023 04:11:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wrrvQf/dGI/1huiCFfc1GA/mIQf2sK7tqSe5vCtEJKPZge690jcZcWtd5mVsVzvGT4x25 X-Received: by 2002:a05:6808:23ca:b0:3a1:b938:e9df with SMTP id bq10-20020a05680823ca00b003a1b938e9dfmr2684479oib.31.1688123501150; Fri, 30 Jun 2023 04:11:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688123501; cv=none; d=google.com; s=arc-20160816; b=kamXJI932H4dbGJ+tDdqPZCZ5b8QDFP3Y9EdseoZVx591CpWo5/CTg07LGwLjdUJ8e CGiPqiFFn0bUKHm+8QbBGdwurSAb6P0l4lJ1JA14dIank7dHv6U2N80DP/8prqA/IFLh LqZoQuFtoH2hX8VWUHPwqWmB8LLooEzE2hTiJHG50dqA6hM0jN2M60Hp4NALf4Tkat4K 8J7Ur6UYd+N0Q/e4pU9U7Hcwv3rg9S01gir0DmrrBFCBAyym9m6t3anVl7hlN9IRsUct nTr7xBL/ziFW+VvABwebtwp0Le8QQtYzJGIcNJEe5ZAgXftcQwUdNR1aYQOCNrLi31nj 2TEw== 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=NiLvcPYr5rj1pPYUeYq5N4/y66efAYaos4OkfirGZYs=; fh=fHzCyx2lgDg5rzxkd+fn4L1zIOfYfCj3lN8BN24cVWY=; b=wfrsea/6AyXWmb0JT/UNt59zVZ7IgBUyQudS05DWNI9/QzM1lK4gXgJ5JnHa3nPXhH 9gMpncV2FW5EnENfY7STI5zMJfUUQxstfbW85ImktYOO3Q0gtDYfBxIvtBM2uWfUMFw3 wrWIp5G+HTM1cV7vrj/lQBW5E5Vb/zEZljZ1FwKghjlVBwtMmsklVXoG+1idux4xigVk nNR/nu3SxxIiA6sY4iwTZGOs/IPnMknRAQyR7QuU6l8QT8//DgSN4OGKmqpDJeJgV1gc 4fkI9pCC1TNvFjTPNrjsynGA0ohO4XULeB2AAVsaeAQV6pEeF/xMSMcLXRhVx1d6vOnq Fm1g== 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 mq3-20020a17090b380300b002611518b4aesi223594pjb.101.2023.06.30.04.11.04; Fri, 30 Jun 2023 04:11:41 -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 S230125AbjF3LKu (ORCPT + 99 others); Fri, 30 Jun 2023 07:10:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbjF3LKu (ORCPT ); Fri, 30 Jun 2023 07:10:50 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B332A10B; Fri, 30 Jun 2023 04:10:48 -0700 (PDT) Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QsszM4fSRzTlsq; Fri, 30 Jun 2023 19:09:51 +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:46 +0800 From: Baokun Li To: CC: , , , , , , , Subject: [PATCH v3 1/5] quota: factor out dquot_write_dquot() Date: Fri, 30 Jun 2023 19:08:18 +0800 Message-ID: <20230630110822.3881712-2-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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 Refactor out dquot_write_dquot() to reduce duplicate code. Signed-off-by: Baokun Li --- V2->V3: No change. fs/quota/dquot.c | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index e3e4f4047657..108ba9f1e420 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -628,6 +628,18 @@ int dquot_scan_active(struct super_block *sb, } EXPORT_SYMBOL(dquot_scan_active); +static inline int dquot_write_dquot(struct dquot *dquot) +{ + int ret = dquot->dq_sb->dq_op->write_dquot(dquot); + if (ret < 0) { + quota_error(dquot->dq_sb, "Can't write quota structure " + "(error %d). Quota may get out of sync!", ret); + /* Clear dirty bit anyway to avoid infinite loop. */ + clear_dquot_dirty(dquot); + } + return ret; +} + /* Write all dquot structures to quota files */ int dquot_writeback_dquots(struct super_block *sb, int type) { @@ -658,16 +670,9 @@ int dquot_writeback_dquots(struct super_block *sb, int type) * use count */ dqgrab(dquot); spin_unlock(&dq_list_lock); - err = sb->dq_op->write_dquot(dquot); - if (err) { - /* - * Clear dirty bit anyway to avoid infinite - * loop here. - */ - clear_dquot_dirty(dquot); - if (!ret) - ret = err; - } + err = dquot_write_dquot(dquot); + if (err && !ret) + ret = err; dqput(dquot); spin_lock(&dq_list_lock); } @@ -765,8 +770,6 @@ static struct shrinker dqcache_shrinker = { */ void dqput(struct dquot *dquot) { - int ret; - if (!dquot) return; #ifdef CONFIG_QUOTA_DEBUG @@ -794,17 +797,7 @@ void dqput(struct dquot *dquot) if (dquot_dirty(dquot)) { spin_unlock(&dq_list_lock); /* Commit dquot before releasing */ - ret = dquot->dq_sb->dq_op->write_dquot(dquot); - if (ret < 0) { - quota_error(dquot->dq_sb, "Can't write quota structure" - " (error %d). Quota may get out of sync!", - ret); - /* - * We clear dirty bit anyway, so that we avoid - * infinite loop here - */ - clear_dquot_dirty(dquot); - } + dquot_write_dquot(dquot); goto we_slept; } if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { -- 2.31.1