lookup_open() takes the parent directory's i_rwsem with inode_lock(), that is, in the I_MUTEX_NORMAL class, before creating the last component. Every other VFS path that locks a directory in order to create something in it goes through start_dirop() and friends, which use inode_lock_nested(dir, I_MUTEX_PARENT). Lock the parent as I_MUTEX_PARENT here too, so that lookup_open() matches the rest of the VFS before it starts calling ->mkdir(), which until now was only ever reached with the parent held that way. No functional change intended. Signed-off-by: Jori Koolstra --- fs/namei.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 8b8e248edfeb..efd0e2e5fbf8 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4483,10 +4483,11 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, * a different error; we'll be dropping this one anyway. */ } + if (shared_flag) - inode_lock_shared(dir_inode); + inode_lock_shared_nested(dir_inode, I_MUTEX_PARENT); else - inode_lock(dir_inode); + inode_lock_nested(dir_inode, I_MUTEX_PARENT); if (unlikely(IS_DEADDIR(dir_inode))) { dentry = ERR_PTR(-ENOENT); -- 2.56.0