Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3271709pxb; Fri, 4 Feb 2022 05:18:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsE4WCtYh5yqpNfE2XdQXZon3uHUamVcV38DScQWi/6du5P9MxDmtt+ag6T8blVy9pfMgH X-Received: by 2002:a17:907:96aa:: with SMTP id hd42mr2455706ejc.13.1643980703339; Fri, 04 Feb 2022 05:18:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643980703; cv=none; d=google.com; s=arc-20160816; b=rXKgSOiRAToelUtHsRnRtlbkvrKCP+mZkOze8b7IfrtKaM0WK8IB7SZU+1AYMHkMYL /pBoLDjPmvOWbpsAjndSQqrBboo6Sy685KoKlEmWIbkVh9bcbsy8uGgfKovnctt5zaoV EACwoRI6VoA105RYyrmnrMBdrTx+QJcOX/m7pdE8L7XJNm3oA0iq+xESqRJ3Et/Mtz5z Ubqgxqk81PtEbnz+MdesOIRteikDFH8GKv0pJDYuRlYG7L7HrM/CVVKNimiM7CqNXqez FqoNN4sq6LdBgy6VxC1sU93NKfdAx+HN8Ip5gQ4p4eNsh9w43xowrmjt3CN1bA6vopMe OXvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id; bh=/FuSSc9ijVQypCn7yLe54rlMbjghecxRgSytaaKdtYM=; b=z9J+CQxtYDVg9jzc5WFWC1F71EHI6aLjUEZS8CXmIXyYidEyqQoEKEI1oFGNPNzErS 7ryPM2TELMNpXhwR/c/7yqhoK31j8reWjA6R4MbP0f59h3Sd3Z1KmKYI/IVM5wsz0cj1 FnAJW7fpRrqpbkiw5wNtA/mHhhvMlF4D61ygM0RqTiWSoFelIZuZXfupnyxq4LKvXp9+ o5M10SnLDCAjU2xnj43Wyourb3JyF5wFbAkCKa0iEyebuP0D40nyKY+lESzYYYQ7Ed3H 1fnL+cW6sRpCUArxH4T4a2dUS+p1OJi/sjBVONOfN/b0j738twab9Q7VdQzxwT16G/KK SMwg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn39si1259020ejc.811.2022.02.04.05.17.46; Fri, 04 Feb 2022 05:18:23 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346833AbiBBTAl (ORCPT + 99 others); Wed, 2 Feb 2022 14:00:41 -0500 Received: from sandeen.net ([63.231.237.45]:35998 "EHLO sandeen.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbiBBTAj (ORCPT ); Wed, 2 Feb 2022 14:00:39 -0500 Received: from [10.0.0.147] (liberator.sandeen.net [10.0.0.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sandeen.net (Postfix) with ESMTPSA id 2E04C78D1; Wed, 2 Feb 2022 13:00:18 -0600 (CST) Message-ID: <789e83e5-c346-86de-3c62-f4fcf35a2bf0@sandeen.net> Date: Wed, 2 Feb 2022 13:00:38 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Content-Language: en-US To: Lukas Czerner , tytso@mit.edu Cc: linux-ext4@vger.kernel.org, Ye Bin References: <20220201131345.77591-1-lczerner@redhat.com> From: Eric Sandeen Subject: Re: [PATCH] ext4: fix remount with 'abort' option In-Reply-To: <20220201131345.77591-1-lczerner@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 2/1/22 7:13 AM, Lukas Czerner wrote: > After commit 6e47a3cc68fc ("ext4: get rid of super block and sbi from > handle_mount_ops()") the 'abort' options stopped working. This is > because we're using ctx_set_mount_flags() helper that's expecting an > argument with the appropriate bit set, but instead got > EXT4_MF_FS_ABORTED which is a bit position. ext4_set_mount_flag() is > using set_bit() while ctx_set_mount_flags() was using bitwise OR. > > Create a separate helper ctx_set_mount_flag() to handle setting the > mount_flags correctly. > > While we're at it clean up the EXT4_SET_CTX macros so that we're only > creating helpers that we actually use to avoid warnings. > > Fixes: 6e47a3cc68fc ("ext4: get rid of super block and sbi from handle_mount_ops()") > Signed-off-by: Lukas Czerner > Cc: Ye Bin ok thinking out loud here - reducing this to the functional change that fixes the bug, (apologies for the surely-mangled whitespace, I'm being lazy), it looks something like: diff --git a/fs/ext4/super.c b/fs/ext4/super.c index eee0d9ebfa6c..a3047b033053 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2045,8 +2045,8 @@ struct ext4_fs_context { unsigned int mask_s_mount_opt; unsigned int vals_s_mount_opt2; unsigned int mask_s_mount_opt2; - unsigned int vals_s_mount_flags; - unsigned int mask_s_mount_flags; + unsigned long vals_s_mount_flags; + unsigned long mask_s_mount_flags; unsigned int opt_flags; /* MOPT flags */ unsigned int spec; u32 s_max_batch_time; @@ -2165,7 +2165,13 @@ ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag) \ EXT4_SET_CTX(flags); EXT4_SET_CTX(mount_opt); EXT4_SET_CTX(mount_opt2); -EXT4_SET_CTX(mount_flags); + +/* Setting the mount_flags field is special, it takes a bit number */ +static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit) +{ + set_bit(bit, &ctx->mask_s_mount_flags); + set_bit(bit, &ctx->vals_s_mount_flags); +} static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) { @@ -2235,7 +2241,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) param->key); return 0; case Opt_abort: - ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED); + ctx_set_mount_flag(ctx, EXT4_MF_FS_ABORTED); return 0; case Opt_i_version: ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20"); and that makes sense to me. I wonder if there's any further cleanup that could make it slightly more clear or foolproof re: which flag matches which ctx_set_* generated function, so the wrong thing doesn't get sent to the wrong routine, but that's a different issue, so for the patch as you sent it, Reviewed-by: Eric Sandeen > --- > fs/ext4/super.c | 29 +++++++++++++++++++++-------- > 1 file changed, 21 insertions(+), 8 deletions(-) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index eee0d9ebfa6c..6f74cd51df2e 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -2045,8 +2045,8 @@ struct ext4_fs_context { > unsigned int mask_s_mount_opt; > unsigned int vals_s_mount_opt2; > unsigned int mask_s_mount_opt2; > - unsigned int vals_s_mount_flags; > - unsigned int mask_s_mount_flags; > + unsigned long vals_s_mount_flags; > + unsigned long mask_s_mount_flags; > unsigned int opt_flags; /* MOPT flags */ > unsigned int spec; > u32 s_max_batch_time; > @@ -2149,23 +2149,36 @@ static inline void ctx_set_##name(struct ext4_fs_context *ctx, \ > { \ > ctx->mask_s_##name |= flag; \ > ctx->vals_s_##name |= flag; \ > -} \ > +} > + > +#define EXT4_CLEAR_CTX(name) \ > static inline void ctx_clear_##name(struct ext4_fs_context *ctx, \ > unsigned long flag) \ > { \ > ctx->mask_s_##name |= flag; \ > ctx->vals_s_##name &= ~flag; \ > -} \ > +} > + > +#define EXT4_TEST_CTX(name) \ > static inline unsigned long \ > ctx_test_##name(struct ext4_fs_context *ctx, unsigned long flag) \ > { \ > return (ctx->vals_s_##name & flag); \ > -} \ > +} > > -EXT4_SET_CTX(flags); > +EXT4_SET_CTX(flags); /* set only */ > EXT4_SET_CTX(mount_opt); > +EXT4_CLEAR_CTX(mount_opt); > +EXT4_TEST_CTX(mount_opt); > EXT4_SET_CTX(mount_opt2); > -EXT4_SET_CTX(mount_flags); > +EXT4_CLEAR_CTX(mount_opt2); > +EXT4_TEST_CTX(mount_opt2); > + > +static inline void ctx_set_mount_flag(struct ext4_fs_context *ctx, int bit) > +{ > + set_bit(bit, &ctx->mask_s_mount_flags); > + set_bit(bit, &ctx->vals_s_mount_flags); > +} > > static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) > { > @@ -2235,7 +2248,7 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param) > param->key); > return 0; > case Opt_abort: > - ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED); > + ctx_set_mount_flag(ctx, EXT4_MF_FS_ABORTED); > return 0; > case Opt_i_version: > ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20");