[PATCH] e2fsck: do not skip deeper checkers when s_last_orphan list has truncated inodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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<y>? no
    Inode 188, i_blocks is 2, should be 0.  Fix<y>? 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 <zhanchengbin1@xxxxxxxxxx>
---
 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");







[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux