[v4,1/2] ext4: commit super block if fs record error when journal record without error
Message ID | 20230301115909.184772-2-yebin@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3582316wrd; Wed, 1 Mar 2023 03:46:10 -0800 (PST) X-Google-Smtp-Source: AK7set+o1voQWh27uHgxfUekAN2FDM1ZlNOajKq0EqRmdpnKysHCw3ynlf5KedigOhkFnhdin3Rf X-Received: by 2002:a05:6402:4d:b0:4ac:cb71:42c with SMTP id f13-20020a056402004d00b004accb71042cmr6222346edu.37.1677671170202; Wed, 01 Mar 2023 03:46:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677671170; cv=none; d=google.com; s=arc-20160816; b=u+ECOBs9s+xsBZNZWS8Q9LzbqDPhu1degIwIqt0+ZXwnbeYClE0IHVBLCkzzGh8qdP K3VYS7RZ4X69bCx5QLnC1vOBCWdk7Ijly2mc58IFK9ya1yMMxYgQPIU3+187sdfQNiEy nj1oPI8fREIkNoZClfgxy58SczZCWK2LjgDx3OSQRiPfgGiu0GirJUcSklz/YnoZw5Io bTXHlL7IDYYrIBq1KO3+nMSFXDHSHI5AvapLECdBiRduNTIfBTTjJcWETOD384cHeIXW wEx6CUEN9rwWF+eMGIlTdPTmSkWcoYbbN1bDcIpA9o619latEJKwpr7rBWSOuctmzSVH pG+Q== 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; bh=gMCJ8ArVAFEmCq/UHNOP4c8xVyKl0XHNL9GEHWBLZl0=; b=VI2EOguQ41DKECao+8mrAQbMFBHjMcLDXhxIhvc2w7wDiKhY+kwH+twsx+E3A31uKG +Bc1BDYoaqJp9jTKRlAvdYqPyqWHrE2n4oBYsdANPPhwP5t8ySIWRsy1bYUKol3j6box t1I8xQPKnDmuyZ/0uSelgDQ8oh3a8IBSEOPjuP0sc0dJNyvFTTAtrwx1f9s/DNVWP8aF 8udeIScZ14v+yb2adV/fSDSFfF0lIGUBMGdbVfuWAAyzf+VY7y+bdM4xpfuxFv3Dq1wz c8nwKxa4GDpEpl9wTet5PgFTWZvSRTbCavn18UA7Mo15X0oxnIWxH38R1jIXPjT1bfza RmFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u2-20020aa7d0c2000000b004ace74aa18esi202687edo.402.2023.03.01.03.45.46; Wed, 01 Mar 2023 03:46:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230064AbjCALgA (ORCPT <rfc822;david.simonyants@gmail.com> + 99 others); Wed, 1 Mar 2023 06:36:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbjCALfz (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 1 Mar 2023 06:35:55 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B75962DE47; Wed, 1 Mar 2023 03:35:54 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PRXH95vpLz4f3jJ7; Wed, 1 Mar 2023 19:35:49 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDHcyGVOP9jOXabEA--.39702S5; Wed, 01 Mar 2023 19:35:51 +0800 (CST) From: Ye Bin <yebin@huaweicloud.com> To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin <yebin10@huawei.com> Subject: [PATCH v4 1/2] ext4: commit super block if fs record error when journal record without error Date: Wed, 1 Mar 2023 19:59:08 +0800 Message-Id: <20230301115909.184772-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230301115909.184772-1-yebin@huaweicloud.com> References: <20230301115909.184772-1-yebin@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _Ch0CgDHcyGVOP9jOXabEA--.39702S5 X-Coremail-Antispam: 1UD129KBjvJXoW7ArWDArWxCF48tw1kJF1fJFb_yoW8GF45pr s5Cr1vgrWqvr18uanrWFsrX34kX34IkayUGr9293WkXa9xtr9avrZ0yFyYkFyjgrW8Ww10 qFyUJ343Kwn5Kr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvlb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV WxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x07U_pnPUUUUU= X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759165725270926937?= X-GMAIL-MSGID: =?utf-8?q?1759165725270926937?= |
Series |
fix error flag covered by journal recovery
|
|
Commit Message
Ye Bin
March 1, 2023, 11:59 a.m. UTC
From: Ye Bin <yebin10@huawei.com> 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 <yebin10@huawei.com> --- fs/ext4/super.c | 7 +++++++ 1 file changed, 7 insertions(+)
Comments
On Wed 01-03-23 19:59:08, Ye Bin wrote: > From: Ye Bin <yebin10@huawei.com> > > 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 <yebin10@huawei.com> Thanks. The patch looks good to me. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > 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) { > -- > 2.31.1 >
On 2023/3/1 19:59, Ye Bin wrote: > From: Ye Bin <yebin10@huawei.com> > > 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 <yebin10@huawei.com> Looks good to me. Reviewed-by: Baokun Li <libaokun1@huawei.com> > --- > 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) {
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) {