Re: [PATCH] kernfs: allocate inodes outside kernfs_rwsem
From: Shakeel Butt
Date: Thu Oct 15 2026 - 19:40:23 EST
On Thu, Oct 15, 2026 at 03:11:10PM -0700, Shakeel Butt wrote:
[...]
>
> @@ -173,7 +171,7 @@ static struct dentry *kernfs_get_parent_dentry(struct dentry *child)
> struct kernfs_root *root = kernfs_root(kn);
>
> guard(rwsem_read)(&root->kernfs_rwsem);
> - return d_obtain_alias(kernfs_get_inode(child->d_sb, kernfs_parent(kn)));
> + return d_obtain_alias(kernfs_iget(child->d_sb, kernfs_parent(kn)));
Sashiko is complaining that inode allocation has been moved outside kernfs_rwsem
but d_obtain_alias() may still allocate dentry under this lock. The fix is
simple. Something like the following:
scoped_guard(rwsem_read, &root->kernfs_rwsem)
inode = kernfs_iget(child->d_sb, kernfs_parent(kn));
return d_obtain_alias(inode);
I am testing this change and I will wait for human response/review before
sending out the v2 of this patch.