Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1D93C678D4 for ; Thu, 2 Mar 2023 01:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229624AbjCBBaK (ORCPT ); Wed, 1 Mar 2023 20:30:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjCBBaK (ORCPT ); Wed, 1 Mar 2023 20:30:10 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC43E1B33E; Wed, 1 Mar 2023 17:30:08 -0800 (PST) Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4PRth32ct2zKmSx; Thu, 2 Mar 2023 09:25:07 +0800 (CST) Received: from [10.174.177.174] (10.174.177.174) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 2 Mar 2023 09:30:06 +0800 Message-ID: <7d83b111-3fd0-f410-6904-17c830496621@huawei.com> Date: Thu, 2 Mar 2023 09:30:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH v4 1/2] ext4: commit super block if fs record error when journal record without error Content-Language: en-US To: Ye Bin , , , CC: , , Ye Bin References: <20230301115909.184772-1-yebin@huaweicloud.com> <20230301115909.184772-2-yebin@huaweicloud.com> From: Baokun Li In-Reply-To: <20230301115909.184772-2-yebin@huaweicloud.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.174] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml500021.china.huawei.com (7.185.36.21) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 2023/3/1 19:59, Ye Bin wrote: > From: Ye Bin > > Now, 'es->s_state' maybe covered by recover journal. And journal errno > maybe not recorded in journal sb as IO error. ext4_update_super() only > update error information when 'sbi->s_add_error_count' large than zero. > Then 'EXT4_ERROR_FS' flag maybe lost. > To solve above issue just recover 'es->s_state' error flag after journal > replay like error info. > > Signed-off-by: Ye Bin Looks good to me. Reviewed-by: Baokun Li > --- > fs/ext4/super.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index faae05493471..9df8fada2dce 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -5910,7 +5910,9 @@ static int ext4_load_journal(struct super_block *sb, > if (!ext4_has_feature_journal_needs_recovery(sb)) > err = jbd2_journal_wipe(journal, !really_read_only); > if (!err) { > + int err2; > char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL); > + > if (save) > memcpy(save, ((char *) es) + > EXT4_S_ERR_START, EXT4_S_ERR_LEN); > @@ -5919,6 +5921,11 @@ static int ext4_load_journal(struct super_block *sb, > memcpy(((char *) es) + EXT4_S_ERR_START, > save, EXT4_S_ERR_LEN); > kfree(save); > + es->s_state |= cpu_to_le16(EXT4_SB(sb)->s_mount_state & > + EXT4_ERROR_FS); > + /* Write out restored error information to the superblock */ > + err2 = ext4_commit_super(sb); > + err = err ? : err2; > } > > if (err) { -- With Best Regards, Baokun Li .