Skip to contentSkip to conversation

e2fsck: Fix orphan inodes processing

PATCH Superseded Etienne AUJAMES 1 participant 1 message May 29

lore
Share & tools
lore
#0 lore raw

cover e2fsck: Fix orphan inodes processing

e2fsck does not handle properly orphan inodes.

Case 1: bad free_blocks accounting with extent files

 # e2fsck -v /tmp/ext4
 e2fsck 1.47.3-wc2 (11-Nov-2025)
 Truncating orphaned inode 12 (uid=0, gid=0, mode=0100644, size=4096)
 Setting free blocks count to 2554682 (was 2554683)
 /tmp/ext4: clean, 13/655360 files, 66758/2621440 blocks
 # e2fsck -yf /tmp/ext4
 e2fsck 1.47.3-wc2 (11-Nov-2025)
 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 blocks count wrong (2554682, counted=2554683).
 Fix<y>? yes

Case 2: e2fsck does not support orphan inodes with ea_inode

 # e2fsck -yf /tmp/ext4                                
 e2fsck 1.47.3-wc2 (11-Nov-2025)
 Clearing orphaned inode 12 (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
 Regular filesystem inode 13 has EA_INODE flag set. Clear<y>? yes
 Unattached inode 13
 Connect to /lost+found<y>? yes
 Inode 13 ref count is 2, should be 1.  Fix<y>? yes
 Pass 5: Checking group summary information

Patch 1 fixes the first case.
Patch 2 includes quota function in libext2fs (required by patch 2). Patch 3 fixes ext2fs_xattrs_* function to update inode iblk and quota. Patch 4 fixes the second case.

Bugs tracked by: https://jira.whamcloud.com/browse/LU-20049

Etienne AUJAMES (3):
e2fsck: fix orphaned extent files handling
libext2fs: update iblock when using ea_inode feature
libext2fs: add ext2fs_xattrs_release_all() helper

Li Dongyang (1):
libext2fs: add quota to libext2fs

 debugfs/debugfs.c                             |  33 +-
 debugfs/xattrs.c                              |  19 +-
 e2fsck/pass1.c                                |  12 +-
 e2fsck/super.c                                | 295 +++++++++---------
 lib/ext2fs/Makefile.in                        |  43 +++
 lib/ext2fs/ext2fs.h                           |  10 +
 lib/ext2fs/ext_attr.c                         | 268 +++++++++++-----
 lib/ext2fs/i_block.c                          |  14 +
 lib/support/quotaio.h                         |   1 -
 misc/create_inode_libarchive.c                |  35 ++-
 misc/fuse2fs.c                                | 117 +++----
 tests/d_xattr_ea_inode/expect                 | 188 +++++++++++
 tests/d_xattr_ea_inode/name                   |   1 +
 tests/d_xattr_ea_inode/script                 | 104 ++++++
 tests/f_orphan_ea_inode/expect.1              |   6 +
 tests/f_orphan_ea_inode/expect.2              |   7 +
 tests/f_orphan_ea_inode/image.gz              | Bin 0 -> 2139 bytes
 tests/f_orphan_ea_inode/name                  |   1 +
 tests/f_orphan_ea_inode/script                |   3 +
 .../f_orphan_truncate_extents_inode/expect.1  |   3 +
 .../f_orphan_truncate_extents_inode/expect.2  |   7 +
 .../f_orphan_truncate_extents_inode/image.gz  | Bin 0 -> 2854 bytes
 tests/f_orphan_truncate_extents_inode/name    |   1 +
 tests/f_orphan_truncate_extents_inode/script  |   3 +
 24 files changed, 842 insertions(+), 329 deletions(-)
 create mode 100644 tests/d_xattr_ea_inode/expect
 create mode 100644 tests/d_xattr_ea_inode/name
 create mode 100644 tests/d_xattr_ea_inode/script
 create mode 100644 tests/f_orphan_ea_inode/expect.1
 create mode 100644 tests/f_orphan_ea_inode/expect.2
 create mode 100644 tests/f_orphan_ea_inode/image.gz
 create mode 100644 tests/f_orphan_ea_inode/name
 create mode 100644 tests/f_orphan_ea_inode/script
 create mode 100644 tests/f_orphan_truncate_extents_inode/expect.1
 create mode 100644 tests/f_orphan_truncate_extents_inode/expect.2
 create mode 100644 tests/f_orphan_truncate_extents_inode/image.gz
 create mode 100644 tests/f_orphan_truncate_extents_inode/name
 create mode 100644 tests/f_orphan_truncate_extents_inode/script
Signature · 1 line
2.43.7