Skip to content

Commit

Permalink
e2fsck: clear the orphan_file while processing it
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tytso committed Dec 10, 2024
1 parent 5c856fa commit db87cf4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
14 changes: 14 additions & 0 deletions e2fsck/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,16 @@ static int process_orphan_block(ext2_filsys fs,
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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
18 changes: 3 additions & 15 deletions tests/f_clear_orphan_file/expect.1
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit db87cf4

Please sign in to comment.