Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1313373rwb; Fri, 19 Aug 2022 01:07:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ot5x7z9m5t/42lhxwnsBCwLW7wIAfrK4EUHpN6PxAEg0BERlTK6a6RKDn2snsoB2WpSFW X-Received: by 2002:a17:907:8687:b0:730:7c7b:b9ce with SMTP id qa7-20020a170907868700b007307c7bb9cemr4074426ejc.656.1660896422451; Fri, 19 Aug 2022 01:07:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660896422; cv=none; d=google.com; s=arc-20160816; b=J3hlTVUPNRaFfyckPgWf0G7kknenddVtxQn/cU97OAZYM4rkMP49rdaauQXTQ77vPq WMw29NKi/RnhuWkmc1/1Z417ZtlPNynnzs0MS3V5H1NEvQTHi46Rs/0dcXHGLTdzFeQg E+dyUEdErx+KtRR3gj3BpgWkxgPjcOs+6rjo6XfP9LPIU9tx4PaxkQK83VQxzmxKkw7Y ebVKsDWs26rfystjcoiC4yD8ZtI4CtHkVL8TwBVNS5JuUG4PoQw1iqB9Xm3TUqFO9DC5 qDnl3rpP4MxdKMntJZbzI/CBXy4AZL+VdHpEszpF//4te33MuJsnPq/ddntFqBmD8piH gRsA== 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 :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=tMww9WuxBqSR7xyL1mjSUkAO/nbrpaWixmHyRZ5fclY=; b=CHYvuuGoFNc6ayyq6XQcLHcN76RTETJWU1EZDeZlncxSRdbOYFgGRLd7IysFaogtgx MSaxhEdswXAJXT3D56ObdlUDo6CIZ5ZV2NGadUBuTbq1RlCPjWZ669mPRH8DAAMSDKkP UmCk0uGjzOza7HkPy6WuJH3MFHwk/GSXRKoPZL1rcYi9xayiGHqGJTxHmKx3LMA1nogU HHdFbJ5A1Lsjue+zIOOJuq4QgDMtM8U68G7ooNONBV6TGTFw9PeeOy+mv6g17fn/+z5b hOOxsiJVTsbaP3OTloEPpi5f+JuhyHqzHqNAvxSeiGI0f1oRJt2KUTZAd0ub0Y0bGnFe A0xw== 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 qw24-20020a1709066a1800b00731646d634esi2507521ejc.802.2022.08.19.01.06.37; Fri, 19 Aug 2022 01:07:02 -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 S1347270AbiHSIAR (ORCPT + 99 others); Fri, 19 Aug 2022 04:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347227AbiHSIAQ (ORCPT ); Fri, 19 Aug 2022 04:00:16 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C257A52DE4; Fri, 19 Aug 2022 01:00:15 -0700 (PDT) Received: from canpemm500010.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M8Dc20qsbzkWVh; Fri, 19 Aug 2022 15:56:50 +0800 (CST) Received: from [10.174.178.185] (10.174.178.185) by canpemm500010.china.huawei.com (7.192.105.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 19 Aug 2022 16:00:13 +0800 Subject: Re: [PATCH RFC] jbd2: detect old record when do journal scan To: , , References: <20220810013442.3474533-1-yebin10@huawei.com> CC: , From: yebin Message-ID: <62FF430D.9040405@huawei.com> Date: Fri, 19 Aug 2022 16:00:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <20220810013442.3474533-1-yebin10@huawei.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.185] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500010.china.huawei.com (7.192.105.118) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 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 ping... On 2022/8/10 9:34, Ye Bin wrote: > As https://github.com/tytso/e2fsprogs/issues/120 describe tune2fs do not update > j_tail_sequence when do journal recovery. This maybe recover old journal record, > then will lead to file system corruption. > To avoid file system corruption in this case, if detect current transaction's > commit time earlier than previous transaction's commit time when do journal > scan, just return error. > > Signed-off-by: Ye Bin > --- > fs/jbd2/recovery.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c > index f548479615c6..f3def21a96a5 100644 > --- a/fs/jbd2/recovery.c > +++ b/fs/jbd2/recovery.c > @@ -812,8 +812,17 @@ static int do_one_pass(journal_t *journal, > break; > } > } > - if (pass == PASS_SCAN) > + if (pass == PASS_SCAN) { > + if (commit_time < last_trans_commit_time) { > + pr_err("JBD2: old journal record found " > + "in transaction %u\n", > + next_commit_ID); > + err = -EFSBADCRC; > + brelse(bh); > + goto failed; > + } > last_trans_commit_time = commit_time; > + } > brelse(bh); > next_commit_ID++; > continue;