Whamcloud - gitweb
e2fsck: clear the orphan_file while processing it
authorTheodore Ts'o <tytso@mit.edu>
Mon, 9 Dec 2024 22:19:26 +0000 (17:19 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 10 Dec 2024 02:44:37 +0000 (21:44 -0500)
Previously, we cleared the orphan file after pass 5.  This was
unfortunate, because it means that the file system is left in a
corrupted state after running "e2fsck -E journal_only".  By fixing
this, we can also remove a spurious "Orpan file... is not clean"
report from e2fsck.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/super.c
tests/f_clear_orphan_file/expect.1

index d6bbb63..cfc0919 100644 (file)
@@ -424,7 +424,16 @@ return_abort:
                ino = ext2fs_le32_to_cpu(bdata[j]);
                if (release_orphan_inode(ctx, &ino, pd->block_buf))
                        goto return_abort;
+               bdata[j] = 0;
        }
+       if (ext2fs_has_feature_metadata_csum(fs->super)) {
+               tail->ob_checksum =
+                       ext2fs_cpu_to_le32(ext2fs_do_orphan_file_block_csum(fs,
+                                   pd->ino, pd->generation, blk, pd->buf));
+       }
+       pd->errcode = io_channel_write_blk64(fs->io, blk, 1, pd->buf);
+       if (pd->errcode)
+               goto return_abort;
        return 0;
 }
 
@@ -465,6 +474,8 @@ static int process_orphan_file(e2fsck_t ctx, char *block_buf)
        pd.ctx = ctx;
        pd.abort = 0;
        pd.errcode = 0;
+       pd.ino = orphan_inum;
+       pd.generation = orphan_inode.i_generation;
        retval = ext2fs_block_iterate3(fs, orphan_inum,
                                       BLOCK_FLAG_DATA_ONLY | BLOCK_FLAG_HOLE,
                                       orphan_buf, process_orphan_block, &pd);
@@ -482,6 +493,9 @@ static int process_orphan_file(e2fsck_t ctx, char *block_buf)
                                orphan_inum);
                }
                ret = 1;
+       } else {
+               ext2fs_clear_feature_orphan_present(fs->super);
+               ext2fs_mark_super_dirty(fs);
        }
 out:
        ext2fs_free_mem(&orphan_buf);
index 281b131..ea0c1cd 100644 (file)
@@ -18,18 +18,6 @@ Clearing orphaned inode 28 (uid=0, gid=0, mode=0100644, size=0)
 Clearing orphaned inode 29 (uid=0, gid=0, mode=0100644, size=0)
 Clearing orphaned inode 30 (uid=0, gid=0, mode=0100644, size=0)
 Clearing orphaned inode 31 (uid=0, gid=0, mode=0100644, size=0)
-Pass 1: Checking inodes, blocks, and sizes
-Pass 2: Checking directory structure
-Pass 3: Checking directory connectivity
-Pass 4: Checking reference counts
-Pass 5: Checking group summary information
-Free inodes count wrong (2055, counted=2005).
-Fix? yes
-
-Orphan file (inode 12) block 0 is not clean.
-Clear? yes
-
-
-test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 43/2048 files (2.3% non-contiguous), 1650/8192 blocks
-Exit status is 1
+Setting free inodes count to 2005 (was 2055)
+test_filesys: clean, 43/2048 files, 1650/8192 blocks
+Exit status is 0