Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1217785pxb; Tue, 1 Feb 2022 22:51:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEFft/mB0a816TeqeabKYGSSSe147F2dAg+82X1RQ2aClaI53kEZ4Y5yF/kKKZwuIrvJhS X-Received: by 2002:a05:6a00:21c6:: with SMTP id t6mr16538183pfj.81.1643784678688; Tue, 01 Feb 2022 22:51:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643784678; cv=none; d=google.com; s=arc-20160816; b=SlzkK7JNDeMpoWjVFY1lfGa1fdiWxUukIZ54ax0BTcd4s+mtM2gAETgqT7vMPluDvZ iF1al8hDhsal8KgqH4VSRkjv1i3QFEMsa5Tsl60/ZhtIryYnxbr1Pr/Bq3z3jsiZx2ve PtYjeu5fvEVPnHt8Oo/Tizg5v29u2HeUZCpHYR0MribZ8AoWxaHM5ZJuPB4xtzUvCtM1 rNfH1IMAotQx+eqVcCsIKD2SgMLQLy1ldSZEM/OsFMPtuaGN6Ddr44v/X2WnTqTJ0FpX KKlXQSkcMQiCJ0ZJIh4LaDTi/6O0fcNnELQdNzABwDefhDwcqZEWTGfCK8NdP2Q/BM06 R5GA== 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 :dkim-signature; bh=UXC1yw6E8gzLJGmP7/8HrH4mG4ZVe0X6VUv9Tso2fsg=; b=dk5qM4D2god7nWEqsViB1DgmrOw0l7m5Urfgs914DYaq4DplxQH9yyddSfNqClB4M8 +ccOJc1kZst1WEXFnQ6BPlLBWM/Q3RuJclNtzAMbCJydWR6NVGZAWQlQTwee3ED0rTka sj0q3yRK8nsYoaxqqttPNvPLO+o52Z16j5h3hP0qa332c97tBlsp/n64nZbD5zMUJJkb 4j1NQfngowAgmA6NJ5jwPdo6M3GCtmzDgYFia4yxZ+QAHFvkI5cy+xaRw4O7vhbv7o9X gmGWZYefN4jjsTID/yd3e+j5MNFqBV4spwJ+7e0MlFi0fpXFfatHN9Fm1EmXhULqynuT eV2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fTGeNZxK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f129si18023611pgc.77.2022.02.01.22.50.44; Tue, 01 Feb 2022 22:51:18 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fTGeNZxK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238267AbiBANSR (ORCPT + 99 others); Tue, 1 Feb 2022 08:18:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42117 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238172AbiBANSQ (ORCPT ); Tue, 1 Feb 2022 08:18:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643721495; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UXC1yw6E8gzLJGmP7/8HrH4mG4ZVe0X6VUv9Tso2fsg=; b=fTGeNZxKCTWuCVrQ+a8MwFaKY+Cv3rFlR6iAs8QhSRJqD9Skc/Y/9azhJnKCrswDykcsnv Y8HCqcPqRQKKyF9Ab1nH4CHp12MpxlwmY4u7Wf2YUx/bjZW36y7fjdxJIGdl2duaESzOhq XC3UaMei4I1iMErl3I+A0ziVkXzrTgQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-UngBEyHgNmW1ThFxSDzeVw-1; Tue, 01 Feb 2022 08:13:54 -0500 X-MC-Unique: UngBEyHgNmW1ThFxSDzeVw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 574591091DA7; Tue, 1 Feb 2022 13:13:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7196E2634A; Tue, 1 Feb 2022 13:13:52 +0000 (UTC) From: Lukas Czerner To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org, Ye Bin Subject: [PATCH] ext4: fix remount with 'abort' option Date: Tue, 1 Feb 2022 14:13:45 +0100 Message-Id: <20220201131345.77591-1-lczerner@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- 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"); -- 2.31.1