Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AFD4C6FD19 for ; Thu, 16 Mar 2023 11:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229532AbjCPL30 (ORCPT ); Thu, 16 Mar 2023 07:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229850AbjCPL3X (ORCPT ); Thu, 16 Mar 2023 07:29:23 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8563DB53EC; Thu, 16 Mar 2023 04:29:22 -0700 (PDT) Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4PclQS752szKn2s; Thu, 16 Mar 2023 19:29:04 +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.21; Thu, 16 Mar 2023 19:29:20 +0800 From: Baokun Li To: CC: , , , , , , , , Subject: [PATCH 2/3] ext4: add helper to check if flag is changed by ctx Date: Thu, 16 Mar 2023 19:28:31 +0800 Message-ID: <20230316112832.2711783-3-libaokun1@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230316112832.2711783-1-libaokun1@huawei.com> References: <20230316112832.2711783-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: dggems703-chm.china.huawei.com (10.3.19.180) 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 helper to check if flag will be changed, return 1 means it will be set, -1 means it will be cleared, 0 means it will not be changed. Signed-off-by: Baokun Li --- fs/ext4/super.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 5b4a323c218b..fefcd42f34ea 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2042,13 +2042,26 @@ ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag) \ return (ctx->vals_s_##name & flag); \ } +#define EXT4_CHANGED_CTX(name) \ +static inline int \ +ctx_changed_##name(struct ext4_fs_context *ctx, unsigned long flag) \ +{ \ + if (ctx->vals_s_##name & flag) \ + return 1; \ + if (ctx->mask_s_##name & flag) \ + return -1; \ + return 0; \ +} + EXT4_SET_CTX(flags); /* set only */ EXT4_SET_CTX(mount_opt); EXT4_CLEAR_CTX(mount_opt); EXT4_TEST_CTX(mount_opt); +EXT4_CHANGED_CTX(mount_opt); EXT4_SET_CTX(mount_opt2); EXT4_CLEAR_CTX(mount_opt2); EXT4_TEST_CTX(mount_opt2); +EXT4_CHANGED_CTX(mount_opt2); static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit) { @@ -2537,9 +2550,7 @@ static int ext4_check_quota_consistency(struct fs_context *fc, quota_flags = EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA | EXT4_MOUNT_GRPQUOTA | EXT4_MOUNT_PRJQUOTA; - if (quota_loaded && - ctx->mask_s_mount_opt & quota_flags && - !ctx_test_mount_opt(ctx, quota_flags)) + if (quota_loaded && (ctx_changed_mount_opt(ctx, quota_flags) < 0)) goto err_quota_change; if (ctx->spec & EXT4_SPEC_JQUOTA) { -- 2.31.1