From patchwork Tue Mar 7 06:17:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 65281 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2271520wrd; Mon, 6 Mar 2023 22:24:10 -0800 (PST) X-Google-Smtp-Source: AK7set8dI9n0XaCcbR63DfiMh3JZ2ZjhGw5xr29ye5XznP/q1B2ks57JFr/KBm3HhAswCTJ2vdmw X-Received: by 2002:a05:6a20:4289:b0:c2:fb92:3029 with SMTP id o9-20020a056a20428900b000c2fb923029mr16975105pzj.33.1678170250185; Mon, 06 Mar 2023 22:24:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678170250; cv=none; d=google.com; s=arc-20160816; b=TfZp5ZyZj74PESmObfy3KDmHreVw/M8zxGWpPVWpSF21/wWOP5DnJpLmfaS+HAJEry EESuioP/AzPT+CXXr4mbO0jaP+Jf44g61nE3h0U4OYvO8+clsL3IAznhuDt5i3FAM/n4 nNaV1D/3rQ481vFqtEhjVaxRznfplwr1leTVbGIzUGh8oY0kBnF7fCbcPsNiy2YwRaoh q3kSqo3qWBD7X2t4RuSFGwGFpBAKdnTE0a3AZ5NUCvmCexVZLyUJh4AHwA5TT/4W5HeX HuS4+Vixft4oMFUyCaMzqm5R8XeZBR4XwcMX0m1451NG6FzP58zbWQxEJJAripQujjFl OuJQ== 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=8bDj3WEvKp+9CVxtuxfTtFeGi9AKsBCJBEVsQI3Cv0A=; b=s5v+pL8+afGhYvqW/koIx8Vd4jMze0mXP+BPXlJRjPdmuuJjBH6B5WRJU3W/MVNn4l VpTjR81qh78DgoiJp5fk1w96J6LG+Oqi3wOa9zWx9v+WAlO4lA3RUBX07zWM4Sylox15 Qaz52XdZ9f/NBe+wMfmJnQM+4RxY+QjzdhLymNpytrYHvjHQiTixIOTvA6mXOENM9aRy DzBYApigzEO/Dv751tc3du0ekzzNMXP7p6UwbyzaatdsS2VkZ9ot4vzKIK3wTaB+QBfd R8VbD8vA8AjXZEefrr2A7a73qsSeMbIunSmyJZl0joJak4pwakQrCggkRNu/8FncdEsV LWtw== 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 y184-20020a638ac1000000b004fb3547c61bsi11302350pgd.735.2023.03.06.22.23.57; Mon, 06 Mar 2023 22:24: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 S230333AbjCGFyE (ORCPT + 99 others); Tue, 7 Mar 2023 00:54:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbjCGFx5 (ORCPT ); Tue, 7 Mar 2023 00:53:57 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B5C6311E7; Mon, 6 Mar 2023 21:53:56 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4PW4Pq1mY0z4f3jM5; Tue, 7 Mar 2023 13:53:51 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP3 (Coremail) with SMTP id _Ch0CgCnUiBv0QZk79DuEQ--.5436S5; Tue, 07 Mar 2023 13:53:53 +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 v5 1/2] ext4: commit super block if fs record error when journal record without error Date: Tue, 7 Mar 2023 14:17:02 +0800 Message-Id: <20230307061703.245965-2-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230307061703.245965-1-yebin@huaweicloud.com> References: <20230307061703.245965-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCnUiBv0QZk79DuEQ--.5436S5 X-Coremail-Antispam: 1UD129KBjvJXoW7ArWDArWxCF48tw1kJF1fJFb_yoW8GF18pr s5Cr1ktrWUZr1xuanrWa10q34kX34IkayUGrn29w1kX39xt34SvrZYyF1YyFy0grW8Ww10 qFyUtry7Kwn5Kr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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=-0.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,SPF_HELO_NONE,SPF_NONE autolearn=no 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?1759689048011539097?= X-GMAIL-MSGID: =?utf-8?q?1759689048011539097?= 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 88f7b8a88c76..dfa31eea1346 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5920,6 +5920,7 @@ static int ext4_load_journal(struct super_block *sb, err = jbd2_journal_wipe(journal, !really_read_only); if (!err) { char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL); + if (save) memcpy(save, ((char *) es) + EXT4_S_ERR_START, EXT4_S_ERR_LEN); @@ -5928,6 +5929,14 @@ 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 */ + if (!bdev_read_only(sb->s_bdev)) { + int err2; + err2 = ext4_commit_super(sb); + err = err ? : err2; + } } if (err) {