[PATCH v2 00/13] e2fsprogs: Add support for dirdata feature
Artem Blagodarenko <[email protected]> Mon, 27 Jul 2026 17:13:09 -0400
| Newsgroups | org.kernel.vger.linux-ext4 |
|---|---|
| Message-ID | <[email protected]> |
Add support for the INCOMPAT_DIRDATA feature, which allows
storing extra metadata in directory entries beyond the file
name. This provides a unified mechanism for extending directory
entries with additional information, including:
- hashes for encryption + casefold support
- unique 128-bit file identifiers (LUFID)
- high bits of 64-bit inode numbers
- future directory entry extensions
If directory hashes were stored before the dirdata feature was
introduced, the legacy hash format continues to be supported for
backward compatibility.
This series adds e2fsprogs support for DIRDATA, including:
- libext2fs: dirdata infrastructure and helper functions
- e2fsck: validation, repair, and reporting support for
dirdata fields
- debugfs: display of dirdata fields in directory listings
with the -lD option for testing and debugging
- mke2fs/tune2fs: user-visible support for enabling the
dirdata filesystem feature
The series also adds regression tests covering directory
optimization, duplicate directory entries, and dirdata field
preservation to ensure metadata integrity and prevent directory
corruption.
The companion kernel series is:
[PATCH v6 00/11] Data in direntry (dirdata) feature
Changes in v2:
- debugfs ls -lD: fixed LUFID printing to copy the dirdata bytes into
a local struct lu_fid via memcpy before byte-swapping and printing,
instead of casting a potentially unaligned pointer in-place
(adilger review).
- debugfs ls -lD: added a loop to print all LUFIDs stored in a single
dirdata entry as a comma-separated list, not only the first one
(adilger review).
- debugfs ls -lD: added labeled formatting for EXT4_DIRENT_CFHASH
("hash: 0x%08x, minor_hash: 0x%08x") and a generic hex dump
fallback for unknown dirdata types (adilger review).
- debugfs ls: fixed the -D option position in the usage string to
follow -d alphabetically (adilger review).
- mke2fs/tune2fs: removed restrictions that blocked dirdata from being
combined with casefold, fscrypt, or inline_data. These were
Lustre-specific osd-ldiskfs limitations, not upstream ext4
constraints (adilger review).
- mke2fs/tune2fs: switched from raw s_feature_incompat flag tests to
the ext2fs_has_feature_dirdata() accessor throughout (adilger review).
- ext2_get_dirdata_field_size(): removed the spurious +1 (NUL
terminator) from individual field sizes; the NUL separator byte is
accounted for only in ext2_get_dirdata_size() (adilger review; this
was causing off-by-one errors in pass2 dirdata validation).
- get_dirent_fid() in message.c: changed the signature to return the
FID array as an out-parameter and the byte count as the return value,
allowing the caller to print all FIDs comma-separated (adilger review).
- pass3 fix_dotdot_proc(): preserve the dirdata bits in name_len when
adjusting the dotdot entry's inode number.
- ext2fs_get_dx_root_info(): use EXT2_DIRENT_REC_LEN(de) instead of
EXT2_NEXT_DIRENT(de) to step past the dotdot entry, so dirdata
appended to the dotdot dirent is correctly skipped (adilger review).
Artem Blagodarenko (13):
ext2fs: Consolidate duplicate min/max macros
ext2fs: Clean up directory entry handling APIs
ext2fs: dirdata infrastructure and core functions
libext2fs: add helper for dx_root_info lookup
e2fsck: pass2 dirdata validation and repair
e2fsck: dirdata message formatting and pass3 support
e2fsck: directory rehashing with dirdata support
debugfs: add dirdata display support
mke2fs/tune2fs: add dirdata feature support
e2fsck: add test suite for directory optimization
e2fsck: add test suite for duplicate directory entries
e2fsck: add test suite for dirdata-specific optimization
ext2fs: share list_dirdata code
debugfs/debugfs.8.in | 7 +-
debugfs/htree.c | 2 +-
debugfs/ls.c | 14 +-
debugfs/ncheck.c | 3 +
e2fsck/message.c | 2 +
e2fsck/pass1.c | 4 +-
e2fsck/pass2.c | 151 +++++++--
e2fsck/pass3.c | 7 +
e2fsck/problem.c | 5 +
e2fsck/problem.h | 3 +
e2fsck/rehash.c | 235 +++++++++-----
lib/ext2fs/alloc.c | 2 -
lib/ext2fs/dirblock.c | 89 ++++++
lib/ext2fs/ext2_fs.h | 47 ++-
lib/ext2fs/ext2fs.h | 32 +-
lib/ext2fs/fallocate.c | 1 -
lib/ext2fs/inline_data.c | 14 +-
lib/ext2fs/lfsck.h | 47 +++
lib/ext2fs/link.c | 11 +-
lib/ext2fs/newdir.c | 4 +-
misc/e4defrag.c | 1 -
misc/mke2fs.c | 1 +
misc/tune2fs.c | 2 +
tests/f_dir_optimize/expect.1 | 511 ++++++++++++++++++++++++++++++
tests/f_dir_optimize/expect.2 | 511 ++++++++++++++++++++++++++++++
tests/f_dir_optimize/image.gz | Bin 0 -> 102520 bytes
tests/f_dir_optimize/name | 1 +
tests/f_dir_optimize/script | 36 +++
tests/f_dirdata_dup_de/expect.1 | 37 +++
tests/f_dirdata_dup_de/expect.2 | 7 +
tests/f_dirdata_dup_de/image.gz | Bin 0 -> 79307 bytes
tests/f_dirdata_dup_de/name | 1 +
tests/f_dirdata_mfid/expect.1 | 35 ++
tests/f_dirdata_mfid/expect.2 | 7 +
tests/f_dirdata_mfid/image.gz | Bin 0 -> 116296 bytes
tests/f_dirdata_mfid/name | 1 +
tests/f_dirdata_optimize/expect.1 | 10 +
tests/f_dirdata_optimize/expect.2 | 7 +
tests/f_dirdata_optimize/image.gz | Bin 0 -> 32121 bytes
tests/f_dirdata_optimize/name | 1 +
tests/f_dirdata_optimize/script | 3 +
41 files changed, 1719 insertions(+), 133 deletions(-)
create mode 100644 lib/ext2fs/lfsck.h
create mode 100644 tests/f_dir_optimize/expect.1
create mode 100644 tests/f_dir_optimize/expect.2
create mode 100644 tests/f_dir_optimize/image.gz
create mode 100644 tests/f_dir_optimize/name
create mode 100644 tests/f_dir_optimize/script
create mode 100644 tests/f_dirdata_dup_de/expect.1
create mode 100644 tests/f_dirdata_dup_de/expect.2
create mode 100644 tests/f_dirdata_dup_de/image.gz
create mode 100644 tests/f_dirdata_dup_de/name
create mode 100644 tests/f_dirdata_mfid/expect.1
create mode 100644 tests/f_dirdata_mfid/expect.2
create mode 100644 tests/f_dirdata_mfid/image.gz
create mode 100644 tests/f_dirdata_mfid/name
create mode 100644 tests/f_dirdata_optimize/expect.1
create mode 100644 tests/f_dirdata_optimize/expect.2
create mode 100644 tests/f_dirdata_optimize/image.gz
create mode 100644 tests/f_dirdata_optimize/name
create mode 100644 tests/f_dirdata_optimize/script
--
2.43.7