From: Baokun Li <libaokun1@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>, <jack@suse.cz>,
<ritesh.list@gmail.com>, <linux-kernel@vger.kernel.org>,
<yi.zhang@huawei.com>, <yangerkun@huawei.com>,
<yukuai3@huawei.com>, <libaokun1@huawei.com>
Subject: [PATCH 2/3] ext4: add helper to check if flag is changed by ctx
Date: Thu, 16 Mar 2023 19:28:31 +0800 [thread overview]
Message-ID: <20230316112832.2711783-3-libaokun1@huawei.com> (raw)
In-Reply-To: <20230316112832.2711783-1-libaokun1@huawei.com>
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 <libaokun1@huawei.com>
---
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
next prev parent reply other threads:[~2023-03-16 11:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 11:28 [PATCH 0/3] ext4: fix WARNING in ext4_add_complete_io Baokun Li
2023-03-16 11:28 ` [PATCH 1/3] ext4: correct error ctx->mask_s_##name in ctx_set_##name Baokun Li
2023-03-16 11:28 ` Baokun Li [this message]
2023-03-16 11:28 ` [PATCH 3/3] ext4: fix race between writepages and remount Baokun Li
2023-03-23 11:44 ` Jan Kara
2023-03-23 14:18 ` Baokun Li
2023-03-27 9:35 ` Jan Kara
2023-03-27 11:11 ` Baokun Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230316112832.2711783-3-libaokun1@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox