On Fri, Aug 28, 2026 at 07:28:25PM -0700, Shakeel Butt wrote: > kernfs_test only exercised two xattr calls, so nothing covered the part > of kernfs most exposed to userspace: the dentry cache. > > kernfs nodes appear and disappear from kernel contexts with no VFS > operation driving them, and removal cannot reliably unhash the cached > dentries, so ->d_revalidate() is the correctness backstop. It had no > test at all. > > Add tests that drive kernfs from kernel context rather than through VFS > create/unlink: > > - writing cgroup.subtree_control makes the kernel add and remove files > in every child cgroup, exercising both the negative-dentry revision > check and the deactivation check, > - renaming a network interface renames the sysfs node underneath an > already cached dentry, > - sysfs in a fresh network namespace must show only that namespace's > interfaces, covering the KERNFS_NS tagging paths, > - lookup hammered against concurrent mkdir/rmdir must only ever see > success or an errno meaning "it went away", > - removal-while-open, readdir duplicate detection and a > seekdir()/telldir() round trip over kernfs_dir_pos()'s hash cookie. > > Also the other direction: walking already cached dentries must not > invalidate them. That is not merely a lost optimisation -- > d_invalidate() calls detach_mounts(), so a revalidation that wrongly > fails silently tears down any mount underneath the directory. > > Both filesystems are needed: cgroup2 has no ->rename and is not > namespace tagged, and sysfs cannot be mounted with a controllable set of > children. The config fragment keeps a kernel built via kselftest-merge > from reporting a pass while running almost nothing. > > Verified the suite reacts to a broken backstop rather than passing: > stubbing kernfs_dir_changed() to return false turns 8 of the 11 tests > red. > > Signed-off-by: Shakeel Butt <[email protected]>
Sashiko raised couple of issues, so I will address those and send v2.

