Re: [PATCH 2/3] kernfs: don't hold kernfs_rwsem across dir_emit()
From: Shakeel Butt
Date: Fri Sep 11 2026 - 14:12:35 EST
On Thu, Sep 10, 2026 at 10:24:18AM -1000, Tejun Heo wrote:
> Hello, Shakeel.
>
> On Wed, Sep 09, 2026 at 05:36:49PM -0700, Shakeel Butt wrote:
> > under the lock and emit the copy, and pass it to the resume so that a
> > resume within one call keys on (hash, ns_id, name) and not on the hash
> > alone.
>
> Please split this into a preparation patch for full-key resumption,
> including the name copy, and a separate patch dropping kernfs_rwsem around
> dir_emit(). Keep the existing locking in the preparation patch.
>
> > + pos = kernfs_dir_pos(ns, parent, hash, pos, name, &resumed);
>
> The fast path in kernfs_dir_pos() still accepts the pinned node based on
> active state, parent and hash alone. Please compare the saved name too
> before setting resumed.
>
> For example, akl, ala and baa have the same kernfs hash. If readdir emits
> akl and it is renamed to baa while unlocked, the fast path accepts the
> renamed node and rb_next() skips the unchanged ala. Falling back to the
> saved key would preserve ala.
>
Sounds good, will make these changes in v2. Thanks for taking a look.