Re: [PATCH v4] kernfs: allocate inodes and dentry outside kernfs_rwsem

From: Jori Koolstra

Date: Thu Nov 12 2026 - 09:59:42 EST



> Op 12-11-2026 08:29 EST schreef Shakeel Butt <shakeel.butt@xxxxxxxxx>:
>
>
> 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).

Ah, I didn't notice that.

>
> 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.

Fair enough, I was thinking you added it on purpose becasue ilookup() does
not get the inode_hash_lock lock. But if you see no regression by always
taking the lock, it's cleaner to get rid of the lookup flag.

At any rate, feel free to add:

Reviewed-by: Jori Koolstra (CIQ) <jkoolstra@xxxxxxxxx>