From patchwork Wed Mar 1 11:59:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 62860 Return-Path: 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 + 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 ); 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 To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin 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 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: 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?= 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 Reviewed-by: Jan Kara 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) { From patchwork Wed Mar 1 11:59:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 62861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3582427wrd; Wed, 1 Mar 2023 03:46:24 -0800 (PST) X-Google-Smtp-Source: AK7set8FAYReGkRE2pvfbBCj2ob8fD5Uk5YAmHThRXeX2PrSDkP2eKqmVpRsG1T9jiavwvHgbS65 X-Received: by 2002:aa7:da83:0:b0:4bd:8714:cc54 with SMTP id q3-20020aa7da83000000b004bd8714cc54mr742403eds.36.1677671183846; Wed, 01 Mar 2023 03:46:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677671183; cv=none; d=google.com; s=arc-20160816; b=Y52y+gS+6R5+4o0CvJNAVEDBcZrYzM66loctwgpeqbGCqd43VUdljd3rB3GRtjcB0p 6Rhr5KhsRofyzzGnYBU/FjOyCR54USIZlY7bAR+kMlyVlsfhRegJG9LvvBbnWUThywnt zWKc/FI+M+w7+agcAQK7neth8CIJFLtx9vcji0v6PP7m4G+ZkMCrUEAmXTYOgguCEqs8 axYS9pC0Tz5NyKGlgr1FURJuiMR/CceK3sjvbyQmjeO8MqaAlnDWgrS+RcqFk02hqQUf wQ0WCWG5wtk0ergT0xZFkq6ZP6MNqPDAZNBNVGENrSYeK/iNhDQsLSQxmE7QlU/Ob2At DOcQ== 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=QEBhs12Qu+TS7lbGTIsgSy5T/ui+aRhpzlu2Q63veKw=; b=sLAiJOuiKfU7qI6arbn1dK3/Rz2I/vcRAvh+BzLoyYnsZfbLqSgO1oWkJlfHJS0DKG 9nu2Ecv0aQFJfQy0bEJBjS4UbJUnZVVtU6F9Xub1cT6vEAPVMwkLltZ4zwTiaqC6RcvQ LKwJQJOPKm6xWSsABxSMYfFkrh5TYY053hiMcGTjCVH4+7yQImB1tg9jKegHbBTa4q/g IS3l4kNb9xWLYnKeNbtYl0EbWZ4Gk+/hU8rtPKNN+KF0nS4qyu5PLTRq4+EnEc1eyRUV YEE3G6AmMabgPRsI0aEfTLoFWeIQ9lwpCp38HRdJ8/EIIagAeRosB66IOlsQVyOocvXc QGyA== 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 v18-20020a17090690d200b008e656382899si13546317ejw.678.2023.03.01.03.46.01; Wed, 01 Mar 2023 03:46:23 -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 S230082AbjCALgE (ORCPT + 99 others); Wed, 1 Mar 2023 06:36:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229529AbjCALf4 (ORCPT ); Wed, 1 Mar 2023 06:35:56 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7E322FCE5; 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 4PRXHB0sl3z4f3jYp; Wed, 1 Mar 2023 19:35:50 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgDHcyGVOP9jOXabEA--.39702S6; Wed, 01 Mar 2023 19:35:52 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH v4 2/2] ext4: make sure fs error flag setted before clear journal error Date: Wed, 1 Mar 2023 19:59:09 +0800 Message-Id: <20230301115909.184772-3-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 X-CM-TRANSID: _Ch0CgDHcyGVOP9jOXabEA--.39702S6 X-Coremail-Antispam: 1UD129KBjvdXoWrtryDXF13GrW7XryxXryrZwb_yoWkZrcEq3 yIyan5WrsxAw1xK3WrCan8WwnYvws2vr15X3ZayF15uryDXas5Ca4DWr93urn8urWrKrZ8 tF17ZF1fG3ykXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbsAYFVCjjxCrM7AC8VAFwI0_Xr0_Wr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r15M2 8IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26F 4j6r4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0 oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7V C0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j 6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r 4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF 67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2I x0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2 z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnU UI43ZEXa7IU86wZ7UUUUU== 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759165739227709191?= X-GMAIL-MSGID: =?utf-8?q?1759165739227709191?= From: Ye Bin Now, jounral error number maybe cleared even though ext4_commit_super() failed. This may lead to error flag miss, then fsck will miss to check file system deeply. Signed-off-by: Ye Bin Reviewed-by: Jan Kara Reviewed-by: Baokun Li --- fs/ext4/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 9df8fada2dce..7736c96d5a78 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -6152,11 +6152,13 @@ static int ext4_clear_journal_err(struct super_block *sb, errstr = ext4_decode_error(sb, j_errno, nbuf); ext4_warning(sb, "Filesystem error recorded " "from previous mount: %s", errstr); - ext4_warning(sb, "Marking fs in need of filesystem check."); EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; es->s_state |= cpu_to_le16(EXT4_ERROR_FS); - ext4_commit_super(sb); + j_errno = ext4_commit_super(sb); + if (j_errno) + return j_errno; + ext4_warning(sb, "Marked fs in need of filesystem check."); jbd2_journal_clear_err(journal); jbd2_journal_update_sb_errno(journal);