Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH v15 00/13] Data in direntry (dirdata) feature, with KUnit tests
@ 2026-12-03 18:49 Artem Blagodarenko
  2026-12-03 18:49 ` [PATCH v15 01/13] ext4: validate count against limit in ext4_dx_csum_verify/_set Artem Blagodarenko
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: Artem Blagodarenko @ 2026-12-03 18:49 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso, jack, adilger.kernel, ablagodarenko

The dirdata feature adds a small, self-describing area after the name in
struct ext4_dir_entry_2.  The unused high 4 bits of file_type say which
records follow the NUL after the name; each record starts with a 1-byte
length, so a reader can skip records it does not know.

It is for per-name data that has to come back from readdir without
reading the child inode, and has to stay with the name across rename.
An xattr on the child can do neither without an inode lookup per entry,
which is what very large directories cannot afford.

The on-disk format is not new.  INCOMPAT_DIRDATA was reserved in ext4 in
2010 (f710b4b96ba2), e2fsprogs knows the feature name, and Lustre servers
have written this format for over 15 years through ldiskfs, a patched
ext4.  The series lets upstream ext4 and e2fsck read and write it.

ext4 already keeps one such item after the name: the casefold+fscrypt
hash.  This series gives it a proper record (CFHASH) so it can sit next
to others.  The first new record is LUFID, a 128-bit file identifier
that must survive rename and be visible to readdir.

Lustre is not meant to stay out of tree: the upstreaming project is
under way [1][2], with the client and server expected to be posted for
review around 2027Q1 [3].  The first server submission only has the
in-memory backend; an ext4 backend needs ext4 changes, which are being
prepared separately so they can be reviewed on their own.  dirdata is
one of them, and one of the reasons the Lustre server needs ldiskfs
today.

Patches 01-04 are fixes and cleanups that do not depend on the feature
and can be taken on their own; 02 fixes a bug in current upstream for
casefolded+encrypted directories.  Patches 05-12 are the feature, and
13 adds KUnit tests for it.

The KUnit tests are new in this version.  They reuse the fixture of the
namei.c tests now in ext4 dev, so the dirdata on-disk format is checked
without a disk image: record parsing and corruption checks, htree roots
with dirdata on '.' and '..', make_indexed_dir() and leaf splits with a
LUFID on every entry, rename and RENAME_EXCHANGE, EXT4_IOC_SET_LUFID,
the casefold+fscrypt hash and the index node limits from patch 02.
They run under UML with

  ./tools/testing/kunit/kunit.py run --kunitconfig=fs/ext4

e2fsprogs support is in
  [PATCH v4 00/13] e2fsprogs: Add support for dirdata feature
and fstests coverage in
  [RFC PATCH v6 0/8] ext4: tests for the dirdata feature
Both are unchanged since they were posted with v14.

[1] https://lwn.net/Articles/1025268/
[2] https://wiki.lustre.org/Lustre_Upstreaming_to_Linux_Kernel
[3] "[RFC] Lustre Upstreaming Project Update", linux-fsdevel, 2026-02-23

Changes in v15 (no human review of v14 yet; this addresses the Sashiko
review of v14):

- New patch 13: KUnit tests for dirdata (9 tests), as a second suite,
  ext4_dirdata_test, in namei-test.c next to ext4_namei_test.

- Rebased onto ext4.git dev (aceadbccd428), which moved the htree
  structures and helpers from namei.c into namei.h (b82144c319f9) and
  added KUnit tests for namei.c and dir.c.  The series now changes
  namei.h, and the tests follow the changed signatures of
  ext4_check_dx_root(), dx_release(), dx_root_limit() and
  ext4_find_dest_de().  struct dx_root stays in namei.h as the layout of
  a root without dirdata, and struct dx_root_info is now a top-level
  struct.

- Patches 01 and 04: the count and limit in the "dir seems corrupt"
  messages are added in 01, where the messages are introduced, instead
  of in 04, which is about ext4_dir_entry_is_tail() (Sashiko).  The two
  messages now have the same spacing.

- Patch 06: ext4_check_dx_root() checks '.' as well as '..', and bounds
  the entry after '..' by the checksum tail, so the length of the
  entries make_indexed_dir() moves out cannot underflow (Sashiko on
  08/09).

- Patch 07 (was "ext4: add ext4_dir_entry_len()"): dx_root_limit()
  takes the offset of the dx_entry array, which both callers already
  have, instead of looking the root up again.  New title and message,
  which now also mention the get_dtype() change (Sashiko).

- Patch 08: when do_split() hands over a half with no room for the new
  entry, that half is still dirtied before the error is returned
  (Sashiko).

- Patch 09:
  * a dirdata record that does not fit in its entry is reported as
    corruption by __ext4_check_dir_entry() and dx_get_dx_info(),
    instead of reading as "no dirdata"; the length of an entry then
    never depends on its current rec_len (Sashiko on 06-09);
  * ext4_inlinedir_to_tree() lets ext4_check_dir_entry() report a bad
    entry instead of skipping it silently (Sashiko);
  * the dirdata copy into struct fname in ext4_htree_store_dirent() is
    gone; nothing read it (Sashiko).
  * ext4_insert_dentry() and ext4_init_new_dir() are now inline
    wrappers, so the test exports name ext4_insert_dentry_data() and
    ext4_init_new_dir_data() instead; with CONFIG_EXT4_KUNIT_TESTS=m
    modpost failed on the rebased v14.

- Patch 10: a RENAME_WHITEOUT rename that fails before the old entry is
  replaced no longer rewrites that entry, which dropped its LUFID
  (Sashiko).

- Patch 11: the five readers of the casefold+fscrypt hash go through
  one helper, ext4_dirent_hash_get().  It reads the CFHASH record when
  there is one, and the fixed place after the name only when the entry
  is long enough and carries no other record there.  Previously '.'
  (12 bytes) and corrupted entries were read 8 bytes past their end
  (Sashiko).

- Patch 12 (Sashiko):
  * a failed re-add puts the old entry back into the block it was
    deleted from, not into whichever block a lookup by name picks;
  * fscrypt_prepare_readdir() is called before checking for the key;
  * check_sticky() is mapped to -EPERM;
  * the inode is checked as ext4_lookup() checks it;
  * the idmap is const, following the VFS.

Tested on ext4.git dev:
- every patch builds with W=1, and links vmlinux and modules with the
  ext4 KUnit tests as a module; the tip also builds with DX_DEBUG;
- KUnit (./tools/testing/kunit/kunit.py run --kunitconfig=fs/ext4):
  571/571 on UML, and the ext4-test module passes on x86_64; each of
  three regressions put back by hand (no corruption check in
  dx_get_dx_info(), no bound on the legacy hash read, the fixed root
  limit) fails its dirdata test;
- in a VM, fstests ext4/024, ext4/064-069 and the casefold and encrypt
  groups pass with and without -O dirdata (34 tests each, 4 not run for
  missing hardware or tools); 1k-block directories with 250-byte names
  and 48-byte LUFIDs split cleanly; RENAME_WHITEOUT keeps the LUFID,
  also when it fails with ENOSPC; a multi-level casefolded+encrypted
  directory (12000 entries, with and without dirdata) passes e2fsck v4
  before and after e2fsck -fD and after more kernel inserts.

v14: https://lore.kernel.org/linux-ext4/20261103134921.610047-1-ablagodarenko@thelustrecollective.com/
v13: https://lore.kernel.org/linux-ext4/20261029122413.230409-1-ablagodarenko@thelustrecollective.com/
v12: https://lore.kernel.org/linux-ext4/20260801181227.5198-1-ablagodarenko@thelustrecollective.com/

Artem Blagodarenko (13):
  ext4: validate count against limit in ext4_dx_csum_verify/_set
  ext4: use the e2fsck limit for htree index nodes
  ext4: replace ext4_dir_entry with ext4_dir_entry_2
  ext4: add ext4_dir_entry_is_tail()
  ext4: add dirdata format definitions and access helpers
  ext4: refactor dx_root to support variable dirent sizes
  ext4: size the htree root from where its dx_entry array starts
  ext4: rename ext4_dir_rec_len() and clarify dirdata usage
  ext4: dirdata feature
  ext4: add dirdata LUFID support for directory entry rename
  ext4: add dirdata set/get helpers
  ext4: Add EXT4_IOC_SET_LUFID ioctl for setting LUFID on directory
    entries
  ext4: add KUnit tests for dirdata

 fs/ext4/dir.c             |   25 +-
 fs/ext4/ext4.h            |  318 ++++++++-
 fs/ext4/fast_commit.c     |    1 +
 fs/ext4/fast_commit.h     |    1 +
 fs/ext4/inline.c          |   47 +-
 fs/ext4/ioctl.c           |   87 +++
 fs/ext4/namei-test.c      |  808 +++++++++++++++++++++-
 fs/ext4/namei.c           | 1326 +++++++++++++++++++++++++++++++------
 fs/ext4/namei.h           |   72 +-
 fs/ext4/sysfs.c           |    2 +
 include/uapi/linux/ext4.h |   14 +
 11 files changed, 2415 insertions(+), 286 deletions(-)


base-commit: aceadbccd428fb8e6593b27a3091d961f80225d1
-- 
2.52.0


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

end of thread, other threads:[~2026-12-03 19:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 18:49 [PATCH v15 00/13] Data in direntry (dirdata) feature, with KUnit tests Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 01/13] ext4: validate count against limit in ext4_dx_csum_verify/_set Artem Blagodarenko
2026-12-03 19:03   ` sashiko-bot
2026-12-03 18:49 ` [PATCH v15 02/13] ext4: use the e2fsck limit for htree index nodes Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 03/13] ext4: replace ext4_dir_entry with ext4_dir_entry_2 Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 04/13] ext4: add ext4_dir_entry_is_tail() Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 05/13] ext4: add dirdata format definitions and access helpers Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 06/13] ext4: refactor dx_root to support variable dirent sizes Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 07/13] ext4: size the htree root from where its dx_entry array starts Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 08/13] ext4: rename ext4_dir_rec_len() and clarify dirdata usage Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 09/13] ext4: dirdata feature Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 10/13] ext4: add dirdata LUFID support for directory entry rename Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 11/13] ext4: add dirdata set/get helpers Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 12/13] ext4: Add EXT4_IOC_SET_LUFID ioctl for setting LUFID on directory entries Artem Blagodarenko
2026-12-03 18:49 ` [PATCH v15 13/13] ext4: add KUnit tests for dirdata Artem Blagodarenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox