Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp261695pxp; Wed, 16 Mar 2022 05:25:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjqtlXAGbnf4RcEglav7FaYDcBoqjPrKbLXAU2sknK6akCuU6OlzhiHG2uvi08X5sFwUjU X-Received: by 2002:a63:10c:0:b0:36c:6dd0:44af with SMTP id 12-20020a63010c000000b0036c6dd044afmr27714223pgb.41.1647433512535; Wed, 16 Mar 2022 05:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647433512; cv=none; d=google.com; s=arc-20160816; b=RXGS8/vx+06uuehrgPbsL4gVFhp1N1IpFHP9TgY2OHBnO3UndFb6uhAd0SQVuI6T6B pwqfleNHaFmvvxDz94Szsa1Nw4bFw8Ez32km3YvK6BboSC+d8GF5io1FOKuwLzyxZYGR cfiRwkSgMm0NYBtOHohHCfwnsaznxUo3wnDPVis2IpknBLVFNU8KsCiZfW1g7jdRlIkN mjjTsjsx1dwl2RtzY1otboslUmH/tLWrfEkvSZxAnLNcWq5K58EFsRE38NlVMMQXludC OlASEtqLmPgyOguVo+dTESgzv3o0BW06Epx7Z+G5gXKgqKifcsGtvFjU1HgrhyAYjPMp o00Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:from:cc:to :user-agent:mime-version:date:message-id; bh=a8kWv8zLUuMJH72xQag08aTntegjTC1rdLBHqssflMg=; b=XWEB0EXuCBwyZ87E5fhGFtlETBJNqbBma3FgO+U8ZbqXMjgcR2On1QzN656zQX73LW kVSmMMDKI7+kSJVEUetQ+jFm7UvX/Q/Ye6Hj30TwqbklOU6bwlfA5RbCvTGjqZMV5ssg /meDEiyQ8WCN5b93iO/xrZYuqAoN5Vj0nCv1FTJpFUNolsZSHs8cfS49HJXYuSzumOH9 UoCxvL6pfSGZqz51DFhNeBE9wey+PxP/ZA7ykoVGZ0652eHklP7SPeRXrn76nH90Ju3y xC7ReAl7nOqR8xyrrSDkwP2pu3792nUzRK0xOeEdO6zxZfAONti/9e84mdbjA/M+9ZDC 3mLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m1-20020a656a01000000b0038037f0abc9si2452208pgu.481.2022.03.16.05.24.51; Wed, 16 Mar 2022 05:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345821AbiCOIDO (ORCPT + 99 others); Tue, 15 Mar 2022 04:03:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345754AbiCOIDA (ORCPT ); Tue, 15 Mar 2022 04:03:00 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9555B4BBB8 for ; Tue, 15 Mar 2022 01:01:48 -0700 (PDT) Received: from dggpeml500022.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4KHm2V0G32z1GCTk; Tue, 15 Mar 2022 15:56:50 +0800 (CST) Received: from dggpeml100016.china.huawei.com (7.185.36.216) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 15 Mar 2022 16:01:46 +0800 Received: from [10.174.176.102] (10.174.176.102) by dggpeml100016.china.huawei.com (7.185.36.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 15 Mar 2022 16:01:46 +0800 Message-ID: <647cc60d-18d4-ab53-6c91-52c1f6d29c3a@huawei.com> Date: Tue, 15 Mar 2022 16:01:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 To: Theodore Ts'o CC: , linfeilong , From: zhanchengbin Subject: e2fsck: do not skip deeper checkers when s_last_orphan list has truncated inodes Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.176.102] X-ClientProxiedBy: dggpeml100023.china.huawei.com (7.185.36.151) To dggpeml100016.china.huawei.com (7.185.36.216) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org If the system crashes when a file is being truncated, we will get a problematic inode, and it will be added into fs->super->s_last_orphan. When we run `e2fsck -a img`, the s_last_orphan list will be traversed and deleted. During this period, orphan inodes in the s_last_orphan list with i_links_count==0 can be deleted, and orphan inodes with i_links_count !=0 (ex. the truncated inode) cannot be deleted. However, when there are some orphan inodes with i_links_count !=0, the EXT2_VALID_FS is still assigned to fs->super->s_state, the deeper checkers are skipped with some inconsistency problems. Here, we will clean EXT2_VALID_FS flag when there is orphan inodes with i_links_count !=0 for deeper checkers. Problems with truncated files. [root@localhost ~]# e2fsck -a img img: recovering journal img: Truncating orphaned inode 188 (uid=0, gid=0, mode=0100666, size=0) img: Truncating orphaned inode 174 (uid=0, gid=0, mode=0100666, size=0) img: clean, 484/128016 files, 118274/512000 blocks [root@localhost ~]# e2fsck -fn img e2fsck 1.46.5 (30-Dec-2021) Pass 1: Checking inodes, blocks, and sizes Inode 174, i_blocks is 2, should be 0. Fix? no Inode 188, i_blocks is 2, should be 0. Fix? no Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information img: ********** WARNING: Filesystem still has errors ********** img: 484/128016 files (24.6% non-contiguous), 118274/512000 blocks [root@localhost ~]# e2fsck -a img img: clean, 484/128016 files, 118274/512000 blocks But, if run `e2fsck -f img`, EXT2_VALID_FS flag will be clean, so do `e2fsck -a img` again, can fix this problem. [root@localhost ~]# e2fsck -f img e2fsck 1.46.5 (30-Dec-2021) Pass 1: Checking inodes, blocks, and sizes Inode 174, i_blocks is 2, should be 0. Fix? no Inode 188, i_blocks is 2, should be 0. Fix? no Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information img: ********** WARNING: Filesystem still has errors ********** img: 484/128016 files (24.6% non-contiguous), 118274/512000 blocks [root@localhost ~]# e2fsck -a img img was not cleanly unmounted, check forced. img: Inode 174, i_blocks is 2, should be 0. FIXED. img: Inode 188, i_blocks is 2, should be 0. FIXED. img: 484/128016 files (24.6% non-contiguous), 118274/512000 blocks Signed-off-by: zhanchengbin --- e2fsck/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/e2fsck/super.c b/e2fsck/super.c index 9495e029..f4a414b7 100644 --- a/e2fsck/super.c +++ b/e2fsck/super.c @@ -351,6 +351,7 @@ static int release_orphan_inode(e2fsck_t ctx, ext2_ino_t *ino, char *block_buf) inode.i_dtime = ctx->now; } else { inode.i_dtime = 0; + fs->super->s_state &= ~EXT2_VALID_FS; } e2fsck_write_inode_full(ctx, *ino, EXT2_INODE(&inode), sizeof(inode), "delete_file");