Re: [PATCH 5/6] kernfs: update a directory's times without kernfs_iattr_rwsem

From: Jori Koolstra

Date: Thu Dec 03 2026 - 09:29:42 EST



> Op 18-11-2026 23:01 CET schreef Shakeel Butt <shakeel.butt@xxxxxxxxx>:
>
>
> kernfs_add_one() and __kernfs_remove() update the parent's ctime and
> mtime under kernfs_iattr_rwsem for writing, inside kernfs_rwsem. This
> is where cgroup mkdirs block on Meta fleet: the writer waits for every
> path walk's permission check while it holds kernfs_rwsem and
> cgroup_mutex.
>
> The lock keeps the times stable for getattr, now their only reader, and
> a timespec64 is too wide for a single store. Give the three times a
> seqlock instead. setattr takes it in addition to kernfs_iattr_rwsem,
> adding or removing an entry takes only the seqlock, and getattr retries
> if a write was in progress. Adding or removing an entry reads the clock
> with the seqlock held, so updates store their times in the order they
> happen. A racing stat() can see the new link count with the old times,
> or the reverse.
>
> A directory without iattrs still skips the update.

I know this is not a change in behavior, but what is the reason we start
to care about the a/c/mtime only after we have done a setattr. I understand
that kernfs wants to be very stingy on memory use, but why not leave it out
all together then? Is there anything that needs those times only when the
attrs are not default?

Best,
Jori.