Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2362370rwd; Fri, 2 Jun 2023 08:24:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4U6vIXtCZ+VeJImFow+vA2sz9psD09oye7V0QhKKrrfGGYmXEUlr/qRq/Jj3Sh2xvDixQx X-Received: by 2002:a17:903:2284:b0:1ae:dadc:ca2a with SMTP id b4-20020a170903228400b001aedadcca2amr252261plh.57.1685719448185; Fri, 02 Jun 2023 08:24:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685719448; cv=none; d=google.com; s=arc-20160816; b=voqydYc4xzYcTw4dPQG1OJssdw2dTvWGLofxiKGoGVaDnZS7fRjg9kYvX5rL1aj0TH cDidbc+/m92nvriGaNJVUPVt3cZ1WkkIm6ChRoD8/A0xfBHzNM2rJrfUU4SoiiZNLfJ+ WxN/l+Z7TndE1X7v2Mq0mOuw5k2eR9aqTl2j0y9equilgl5HszbX7sWznx8eH0FbMvWF +Tj6Cqd893vNiALFMYoVs2H3f/1+4jxBfMoCU9dC4HhACQ5WLVbrgFvhci43m/PxvTdR 7yb8ErK+E6ItVA08N71skavgardNUmh2ptYe+aBbi2K1PFoekjVefZymyHgH5FMB0PSN xwjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tswq+l7pZGJtuXjPgATouGHUZJky5MfI0ibpgv9snVc=; b=msUV1/a/qa3L0tzdVlwYUI0fzqhtlQ3DYegY3biQOETsuPl9fVgr4qVpOdR7I09ODb Ft7liQLF/FwUc//ce4TjeLx2Q6yH7ITGWVJbn9g+x4SqCCNeTphPln0zAt+5+20Lkt2t ArJ205ISLK7HbWc+uPNM0RT41lob4Vpz/ANTWA9jDjJF/7Ao5dx8Aop0vjKmCNek0HZ8 v6QPiGe9Yt/lXBguvs5llhXNaXRZrxFzgCvNuFbf36FP/7d6LNrpdAF7NWeqN21lO+Ml 1zQlAk23eqg7JtswHrGHvcM9Br8HqiqW9pIin/mN9J3ncHoyFoumGNIVTxJ8Ybsb/wpJ Xj2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NiF9gmt7; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w21-20020a170902a71500b00192d6fb649dsi1027304plq.242.2023.06.02.08.23.48; Fri, 02 Jun 2023 08:24:08 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NiF9gmt7; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232897AbjFBPTA (ORCPT + 99 others); Fri, 2 Jun 2023 11:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235527AbjFBPTA (ORCPT ); Fri, 2 Jun 2023 11:19:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B78B818C for ; Fri, 2 Jun 2023 08:18:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5375860AB7 for ; Fri, 2 Jun 2023 15:18:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A795DC433EF; Fri, 2 Jun 2023 15:18:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685719138; bh=N8KKtm67jhbNPdeIzSdK7pFIuxNbBcAgHr17j/eAbxE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NiF9gmt7opm1WpmNSmLocX0uIkdhvlQNPsD0cuwGoMuoVJYkHhbWYECuuS5fhccbB cYS5ahMkxI4EVKxi4gHwOWHGmSeemD66gheUUjVusz0JXx2m/h4G33azOMVe+6oYLV jQLGOll7KFOp5ldes55bT1Fld+CsEhNpFjCY2fmSFdZT77G/JAME7Tb8Tn3qp0kMOi yHP06QM4NVZT3PbGQKJcxuunSNJLAdQllUHI+6gcSLyvWaKpzY786T3oo5I3/8Z3Rc gu25k7WtymbLjTM5HLcAH7zogxIc5ScSHQ09UG7rfe/9tMhZD1qyF0SY36h7T2/SwV gU36Qz0GNfz+A== Date: Fri, 2 Jun 2023 08:18:58 -0700 From: "Darrick J. Wong" To: zhanchengbin Cc: tytso@mit.edu, linux-ext4@vger.kernel.org, linfeilong@huawei.com, louhongxiang@huawei.com Subject: Re: [PATCH] e2fsck: restore sb->s_state before journal recover Message-ID: <20230602151858.GA16844@frogsfrogsfrogs> References: <20230602082759.4062633-1-zhanchengbin1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230602082759.4062633-1-zhanchengbin1@huawei.com> X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Fri, Jun 02, 2023 at 04:27:59PM +0800, zhanchengbin wrote: > ext4_handle_error > EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; > if remount-ro > ext4_commit_super(sb); > As you can see, when the filesystem error in the kernel, the last sb commit > not record the journal, So sb->s_state will be overwritten by journal recover. > In some cases , modifying metadata and superblock data are placed in two > transactions, if the previous transaction is already in the journal, and > ext4_handle_error occurs when updating sb, the filesystem is still error even > if the journal is recovered(I know that this situation should not occur in > theory, but I encountered this error when testing quota. Therefore, I think > we cannot fully rely on the kernel). > So when the filesystem is error before the journal recover, keep the error > state and perform deep check later. > > Signed-off-by: zhanchengbin > --- > e2fsck/journal.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/e2fsck/journal.c b/e2fsck/journal.c > index c7868d89..6f49321d 100644 > --- a/e2fsck/journal.c > +++ b/e2fsck/journal.c > @@ -1683,6 +1683,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx) > errcode_t retval, recover_retval; > io_stats stats = 0; > unsigned long long kbytes_written = 0; > + __u16 state = ctx->fs->super->s_state; > > printf(_("%s: recovering journal\n"), ctx->device_name); > if (ctx->options & E2F_OPT_READONLY) { > @@ -1722,6 +1723,9 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx) > ctx->fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; > ctx->fs->super->s_kbytes_written += kbytes_written; > > + if (EXT2_ERROR_FS | state) Isn't this ^^^^^^^^^^^^^^^^^^^^^ expression always nonzero? > + ctx->fs->super->s_state = state | EXT2_ERROR_FS; /me doesn't understand this bit logic at all. --D > + > /* Set the superblock flags */ > e2fsck_clear_recover(ctx, recover_retval != 0); > > -- > 2.31.1 >