diff options
| author | Shakeel Butt <shakeel.butt@linux.dev> | 2026-09-01 18:40:50 -0700 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-09-04 10:06:57 +0200 |
| commit | c38b381d20273f1f3d0f30c019a6020c34815f83 (patch) | |
| tree | a4dd0e473a233facaee4cda65213e649e865af01 /tools/lib/python/kdoc/parse_data_structs.py | |
| parent | e626ea246428d65c362c72849a68be350f2b084f (diff) | |
| download | linux-next-c38b381d20273f1f3d0f30c019a6020c34815f83.tar.gz linux-next-c38b381d20273f1f3d0f30c019a6020c34815f83.zip | |
selftests: cover kernfs dentry revalidation
kernfs_test only checked two xattr calls. It did not touch the part of
kernfs that userspace hits most: the dentry cache.
The kernel adds and removes kernfs nodes on its own, with no VFS call
behind it, and removal cannot always unhash the dentries that are
already cached. So ->d_revalidate() is what keeps the cache honest,
let's add tests for it.
Add tests that make the kernel change kernfs directly, instead of going
through create and unlink:
- writing cgroup.subtree_control makes the kernel add and remove files
in every child cgroup. That checks two things: a cached negative
dentry is dropped once the file appears, and a cached positive one
is dropped once the file goes away.
- renaming a network interface renames the sysfs node under a dentry
that is already cached.
- sysfs mounted in a new network namespace must list that namespace's
interfaces and not the parent's, which covers the KERNFS_NS tagging
code.
- many lookups running against concurrent mkdir and rmdir. A lookup
may only succeed or fail with an errno that means "it is gone".
- open across removal, readdir returning each entry once, and a
telldir()/seekdir() round trip, which uses the name hash cookie in
kernfs_dir_pos().
Test the other direction too: walking dentries that are already cached
must not drop them. That is not just a slowdown. d_invalidate() calls
detach_mounts(), so a dentry dropped by mistake also unmounts whatever
is mounted under that directory.
Both filesystems are needed. cgroup2 has no ->rename and is not
namespace tagged. sysfs cannot be mounted with a set of children we
control. The config fragment stops a kernel built with kselftest-merge
from passing while it runs almost nothing.
To confirm the tests really catch a broken backstop, kernfs_dir_changed()
was stubbed to return false. 8 of the 11 tests then failed.
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Link: https://patch.msgid.link/20260902014050.499002-1-shakeel.butt@linux.dev
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc/parse_data_structs.py')
0 files changed, 0 insertions, 0 deletions
