From patchwork Tue Feb 14 02:29:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 56608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2708108wrn; Mon, 13 Feb 2023 18:16:22 -0800 (PST) X-Google-Smtp-Source: AK7set8NH6Xa9aSYkDIZUi+Wx8t4DbOV+gMMcZ3i/DPPIT1arbi1AOsJ8UzPKihlVQ/+u5dZej3T X-Received: by 2002:a62:1a05:0:b0:593:ed9c:9f07 with SMTP id a5-20020a621a05000000b00593ed9c9f07mr417147pfa.27.1676340982653; Mon, 13 Feb 2023 18:16:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676340982; cv=none; d=google.com; s=arc-20160816; b=DGGTrjO9ToxU07exe9/McCLmJ9LXHVK09NYxiR1/FZaKw0xyFjUJCEck3LiL05c/5l agys7tfTlRSPU07PzxNnoZvbHNaKXkRCyHIz44Pkh0n9zRiuVmnFAkoBjqzoi2/HKVCW oYPg63MAsYlLogtDl6W71Kx1rD1GDkcBJ+NIUoWLY6OjVk/xENeEXq03GIlo2boGof7y qQpr8r++QmWkYYS6ivptDitVr4/+jJ0NZzOvYKQVucxo3dCK5qkUI6uBS2qtjXd5Yd5T pv6ZDd0aErn/rP1kTpJJBA9dkoB5B226dJ0Xx5K26dlJk08p7jnzpmybLKoLnE7YMS3i l21Q== 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=tKYy2SDFiNcLF6buKGmqFbAlMORNzamYAW+pNZFXv1c=; b=rJE5aF+fEuiK3hexI3l7tRQlyELiRXWG+HMkz7bcYQSKvYAv7w74Pjgwq72X9KYRu5 YjfGTQcNXtN7+eK7vGomZ+DqUScLEyF1qGPUq9Zs/f4QYMQgVivMr8fHzSHbWwxJfZRH ++jp+0kcZl4kzBdLWYJWoRgFpNLCnquJweGUckrpmWjzSnOC43oj/TllI14wyxdRq5fb VCXs+N1A42L1JqvFlbPj7EmeuQ79A7UBEhequVo4Jr+tZoaM6WpvKIgnbSWkIBWVbs2j Ue4GM8iA2fA2B8JUkK7WW0gPDPGzVX4BYqZxZxW1EwjLtZ7Y8Bq1cWh87QpqssAVS/2r 8gPw== 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 v129-20020a622f87000000b0059d96ba730dsi11868767pfv.110.2023.02.13.18.16.09; Mon, 13 Feb 2023 18:16:22 -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 S231224AbjBNCFg (ORCPT + 99 others); Mon, 13 Feb 2023 21:05:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229934AbjBNCFc (ORCPT ); Mon, 13 Feb 2023 21:05:32 -0500 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C83D113E2; Mon, 13 Feb 2023 18:05:29 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4PG4Kv6bmNz4f3jHy; Tue, 14 Feb 2023 10:05:23 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCnUiBk7OpjvrkRDQ--.53521S5; Tue, 14 Feb 2023 10:05:26 +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 v3 1/2] ext4: commit super block if fs record error when journal record without error Date: Tue, 14 Feb 2023 10:29:04 +0800 Message-Id: <20230214022905.765088-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230214022905.765088-1-yebin@huaweicloud.com> References: <20230214022905.765088-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCnUiBk7OpjvrkRDQ--.53521S5 X-Coremail-Antispam: 1UD129KBjvJXoWrtrWUJry7uF48tr48ZFWrZrb_yoW8Jr48p3 95Arn7AFZ0vF17CwsrJwsrXFyvg34Fka4UWr1Sk3Z3Aa9xtr9IvrZ8tF15AFWjgrW8Ww1r X34UGay7G3s5Kr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUzoGQUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, 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?1757770922354289951?= X-GMAIL-MSGID: =?utf-8?q?1757770922354289951?= 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 commit error information after recover journal. Signed-off-by: Ye Bin --- fs/ext4/super.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dc3907dff13a..b94754ba8556 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5932,6 +5932,18 @@ static int ext4_load_journal(struct super_block *sb, goto err_out; } + if (unlikely(es->s_error_count && !jbd2_journal_errno(journal) && + !(le16_to_cpu(es->s_state) & EXT4_ERROR_FS))) { + EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; + es->s_state |= cpu_to_le16(EXT4_ERROR_FS); + err = ext4_commit_super(sb); + if (err) { + ext4_msg(sb, KERN_ERR, + "Failed to commit error information, please repair fs force!"); + goto err_out; + } + } + EXT4_SB(sb)->s_journal = journal; err = ext4_clear_journal_err(sb, es); if (err) { From patchwork Tue Feb 14 02:29:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 56607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2707475wrn; Mon, 13 Feb 2023 18:14:44 -0800 (PST) X-Google-Smtp-Source: AK7set/THxBeU4m8Asron86Uxf8WjW9815u1bgmTHhVCRzyWnefhLe8SP1A60RMQDD7TC9FawQxE X-Received: by 2002:a17:902:f28b:b0:19a:75b8:f4ff with SMTP id k11-20020a170902f28b00b0019a75b8f4ffmr776242plc.35.1676340883869; Mon, 13 Feb 2023 18:14:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676340883; cv=none; d=google.com; s=arc-20160816; b=SsUGRzLaX3ybVAupOUOTBxjSraft5uXIEvm2YzmZsyn52KsDuUuYQB1pQFjJErTxIf kS39DIl52M0c7F0yRWeP/BAJMxRBO+IHh1aVhm4+zlrw9kr91iLsDgxx982vIr6LW70g fXoesAHdQ6DwcMbJePAfnoLH6Jjd1lknwGwPzpZBEGTWqyE770nZh8jmjFTbBMw5B7ln ZojVpXw7WYwm/swhU0FtPDzV181bQmlBZpLLUdXX4Qj8uqKEUuXGe1lF2GpILJfC+d/9 slNr+AXVlJgc3VSpYpYOVTy2PeQ7LAjj6hib0LIxAplwlxaL6FIZ/ELD21lMPndRbGr/ 8Mgg== 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=6XgMpQZGGvHAlC1QfWb1MZXsOYsZxVG/TlV8JeiAb7g=; b=js+j/LehI2NO7xtS1xu34nQKvUhDwGzu23YC43/DqSC0MrfTbk1F/xljPVuYuePfRt D/R3g1dASfc2/3DD6CiQ2u6kmz9i694EqNcnjPUFQ/ZwnEaSkazIPYL4lvoMW7YSTio6 gvREziaT3gBmqSz6LxUPfahfp88fTl1BQa4tEj3DoBaBb111CCUrFMUtp8zQQ523oDEX dP7ZSMNGbpCbQTdURavFYvq2W/h9zfpHGeoJFdhSB3rHmE6N/nba/+xl1du3SzpPrxa1 Ha7wtt3fxVo254V6ZXg3ewBDExnSeWRmhXlckud7EMZ/Hz7jOIvI2CjZyJK7izYP4QnI I8qA== 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 g12-20020a170902934c00b0019a59b3c552si12580685plp.531.2023.02.13.18.14.30; Mon, 13 Feb 2023 18:14:43 -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 S231202AbjBNCFd (ORCPT + 99 others); Mon, 13 Feb 2023 21:05:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbjBNCFc (ORCPT ); Mon, 13 Feb 2023 21:05:32 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CA3012F0B; Mon, 13 Feb 2023 18:05:29 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PG4Kw2Snzz4f3jZH; Tue, 14 Feb 2023 10:05:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCnUiBk7OpjvrkRDQ--.53521S6; Tue, 14 Feb 2023 10:05:26 +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 v3 2/2] ext4: make sure fs error flag setted before clear journal error Date: Tue, 14 Feb 2023 10:29:05 +0800 Message-Id: <20230214022905.765088-3-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230214022905.765088-1-yebin@huaweicloud.com> References: <20230214022905.765088-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCnUiBk7OpjvrkRDQ--.53521S6 X-Coremail-Antispam: 1UD129KBjvdXoWrtryDXF13GrW7XryxXryrZwb_yoWkXwbEq3 yxAan5Wrs3Ar1Ika1rCan8Ww1vvws2vFn8X3ZayF15uryDXa4kCa4DWryfurn8urZ5KrZ8 JF18ZFn3GaykXjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbV8YFVCjjxCrM7AC8VAFwI0_Xr0_Wr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r15M2 8IrcIa0xkI8VCY1x0267AKxVW8JVW5JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK 021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r 4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx 0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWU JVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJV W8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF 1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6x IIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvE x4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvj DU0xZFpf9x07jeWlkUUUUU= 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?1757770818483891939?= X-GMAIL-MSGID: =?utf-8?q?1757770818483891939?= 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: Baokun Li Reviewed-by: Jan Kara --- 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 b94754ba8556..619ef6d021d4 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -6163,11 +6163,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);