Re: [PATCH v4] kernfs: allocate inodes and dentry outside kernfs_rwsem
From: Shakeel Butt
Date: Thu Nov 12 2026 - 09:20:29 EST
On Thu, Nov 12, 2026 at 12:38:12PM +0100, Jori Koolstra wrote:
>
> > Op 11-11-2026 16:50 EST schreef Shakeel Butt <shakeel.butt@xxxxxxxxx>:
> >
> >
[...]
> > + new = new_inode(sb);
> > + if (!new)
> > + return -ENOMEM;
> > down_read(&kf_root->kernfs_rwsem);
> > - inode = kernfs_get_inode(sb, info->root->kn);
> > + inode = kernfs_get_inode_locked(new, info->root->kn);
> > up_read(&kf_root->kernfs_rwsem);
> > if (!inode) {
> > pr_debug("kernfs: could not get root inode\n");
> >
> > base-commit: ecdfc51a6a78aaf1c4ac1d8b6ea199cc2ed020ac
> > --
> > 2.53.0-Meta
>
> Does this compile? I added a bool parameter to kernfs_get_inode_locked(),
> for this patch to be able to do a lookup first, but you haven't added that.
> I think you want to set lookup=true everywhere, right?
>
Yes, it builds on vfs-7.5.directory (base-commit ecdfc51a6a78).
Christian's fixup there dropped @lookup, so kernfs_get_inode_locked()
now takes just (inode, kn).
I don't think this patch needs @lookup. inode_insert5() already
returns an inode that is already hashed, so an ilookup() first only
changes things for an inactive node. Lookup and the fh_to_* paths
only get there with an active node, under the same kernfs_rwsem hold,
and fill_super works on a new superblock. In ->get_parent, an
inactive parent means the directory being decoded is being removed.
reconnect_one() then returns -ESTALE either way, because readdir
skips the removed child.