Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6817304rwd; Tue, 6 Jun 2023 02:17:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66YidrXojKAwTihEjFNjn2mZgBEA/4QY7bbfU+DwygtiYZ6IdM49lG68UaEPAja00ngJNi X-Received: by 2002:ac8:5849:0:b0:3f5:7cfa:f5e9 with SMTP id h9-20020ac85849000000b003f57cfaf5e9mr1585468qth.13.1686043029819; Tue, 06 Jun 2023 02:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686043029; cv=none; d=google.com; s=arc-20160816; b=jqiwI0NLukkdJTl62w40F7dDn54/7j9P2eJnZyoylNXQ1g2egofIuaV4lLLdbxU2rk RxDjIyL30FUgqqyOzsL68JeH/60rEsFOyXW78uDgaYQWqbM5UvrscRVEUeBbgMtMkhV5 K3dO9aEOMJRM1LYpzBzW2NhSQA5k2+rQZyH3v7zdVQnz5N9Ht5DpiiSVpHuKGXV9RrqI VDza439+fA3C98EIwUtiXGkrNxfT4fYwgcefTUXalySaSk9AL5U6dnS0OM77qXGmUkgW O6Q9VVZqkssJ057e8reEuhouIQycl7mc/xKV2TeNvXq585bzvzndv9hLlzl+F27wMhGu 5eLA== 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:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=hFfIaFD15ocAT85l0L6WYeFyqsBXf4MegCVqxf61HKc=; b=gGQHacPmBbdTkPcEVpz7wtbWuAaNEr37nVcfXuNoVsohnlauQboDMzQfakrG9s/6ie iTgqAYsq3XKDIttMGDup/xXZ1uxnfgchmuzE6lBSGIzQqnmNESmRSLNDxxhvVdiNUlgL uFAykaJcwYDC2zEGaXELmWq7TWl8JzROYhUEJ6JeZK81vSC/yxdbMKx4VdJv+JMHrflZ pORePS6E33X/f5QVvmnIDt5Z62t0FYpD1JCB84wYGeUZTD/uJqpRNrFQFhq3UZZkgThx bo2YKJvmAiGTEYJuWRUyq8AxPqOcGdIkfhTB0szGiy5GuihJaF5cS5SM4PwC6WnsuChG vZ9A== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020a05622a065000b003f6a49049b0si6146363qtb.180.2023.06.06.02.16.53; Tue, 06 Jun 2023 02:17:09 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230482AbjFFJKL (ORCPT + 99 others); Tue, 6 Jun 2023 05:10:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231371AbjFFJKI (ORCPT ); Tue, 6 Jun 2023 05:10:08 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 830938F for ; Tue, 6 Jun 2023 02:10:07 -0700 (PDT) Received: from dggpeml500016.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Qb4Ll0dTkz18M3M; Tue, 6 Jun 2023 17:05:19 +0800 (CST) Received: from [10.174.176.102] (10.174.176.102) by dggpeml500016.china.huawei.com (7.185.36.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 6 Jun 2023 17:10:04 +0800 Message-ID: <37829291-c0e2-69dc-64d6-feb3b3afed4f@huawei.com> Date: Tue, 6 Jun 2023 17:10:04 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH 1/2] e2fsck: save EXT2_ERROR_FS flag during journal replay To: Baokun Li , CC: , , , , , References: <20230217100922.588961-1-libaokun1@huawei.com> <20230217100922.588961-2-libaokun1@huawei.com> From: zhanchengbin In-Reply-To: <20230217100922.588961-2-libaokun1@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.102] X-ClientProxiedBy: dggpeml100013.china.huawei.com (7.185.36.238) To dggpeml500016.china.huawei.com (7.185.36.70) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 2023/2/17 18:09, Baokun Li wrote: > When repairing a file system with s_errno missing from the journal > superblock but the file system superblock contains the ERROR_FS flag, > the ERROR_FS flag on the file system image is overwritten after the > journal replay, followed by a reload of the file system data from disk > and the ERROR_FS flag in memory is overwritten. Also s_errno is not set > and the ERROR_FS flag is not reset. Therefore, when checked later, no > forced check is performed, which makes it possible to have some errors > hidden in the disk image, which may make it read-only when using the > file system. So we save the ERROR_FS flag to the superblock after the > journal replay, instead of just relying on the jsb->s_errno to do this. > > Signed-off-by: Baokun Li Looks good to me. Feel free to add: Reviewed-by: zhanchengbin - bin. > --- > e2fsck/journal.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/e2fsck/journal.c b/e2fsck/journal.c > index c7868d89..0144aa45 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 s_error_state; > > printf(_("%s: recovering journal\n"), ctx->device_name); > if (ctx->options & E2F_OPT_READONLY) { > @@ -1705,6 +1706,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx) > ctx->fs->io->manager->get_stats(ctx->fs->io, &stats); > if (stats && stats->bytes_written) > kbytes_written = stats->bytes_written >> 10; > + s_error_state = ctx->fs->super->s_state & EXT2_ERROR_FS; > > ext2fs_mmp_stop(ctx->fs); > ext2fs_free(ctx->fs); > @@ -1721,6 +1723,7 @@ errcode_t e2fsck_run_ext3_journal(e2fsck_t ctx) > ctx->fs->now = ctx->now; > ctx->fs->flags |= EXT2_FLAG_MASTER_SB_ONLY; > ctx->fs->super->s_kbytes_written += kbytes_written; > + ctx->fs->super->s_state |= s_error_state; > > /* Set the superblock flags */ > e2fsck_clear_recover(ctx, recover_retval != 0); >