All of lore.kernel.org
 help / color / mirror / Atom feed
* e2fsck: do not skip deeper checkers when s_last_orphan list has truncated inodes
@ 2022-03-15  8:01 zhanchengbin
  2022-03-15 17:54 ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: zhanchengbin @ 2022-03-15  8:01 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4, linfeilong, liuzhiqiang26

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@huawei.com>
---
  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");




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-18 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-15  8:01 e2fsck: do not skip deeper checkers when s_last_orphan list has truncated inodes zhanchengbin
2022-03-15 17:54 ` Theodore Ts'o
2022-03-18 10:14   ` zhanchengbin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.