Skip to content

Commit 09f124b

Browse files
neilbrownsmfrench
authored andcommitted
smb/server: use lookup_one_unlocked()
In process_query_dir_entries(), instead of locking the directory, performing a lookup, then unlocking, we can simply call lookup_one_unlocked(). That takes locks the directory only when needed. This removes the only users of lock_dir() and unlock_dir() so they can be removed. Signed-off-by: NeilBrown <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 89be9a8 commit 09f124b

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,20 +4108,6 @@ struct smb2_query_dir_private {
41084108
int info_level;
41094109
};
41104110

4111-
static void lock_dir(struct ksmbd_file *dir_fp)
4112-
{
4113-
struct dentry *dir = dir_fp->filp->f_path.dentry;
4114-
4115-
inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
4116-
}
4117-
4118-
static void unlock_dir(struct ksmbd_file *dir_fp)
4119-
{
4120-
struct dentry *dir = dir_fp->filp->f_path.dentry;
4121-
4122-
inode_unlock(d_inode(dir));
4123-
}
4124-
41254111
static int process_query_dir_entries(struct smb2_query_dir_private *priv)
41264112
{
41274113
struct mnt_idmap *idmap = file_mnt_idmap(priv->dir_fp->filp);
@@ -4136,12 +4122,10 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv)
41364122
if (dentry_name(priv->d_info, priv->info_level))
41374123
return -EINVAL;
41384124

4139-
lock_dir(priv->dir_fp);
4140-
dent = lookup_one(idmap,
4141-
&QSTR_LEN(priv->d_info->name,
4142-
priv->d_info->name_len),
4143-
priv->dir_fp->filp->f_path.dentry);
4144-
unlock_dir(priv->dir_fp);
4125+
dent = lookup_one_unlocked(idmap,
4126+
&QSTR_LEN(priv->d_info->name,
4127+
priv->d_info->name_len),
4128+
priv->dir_fp->filp->f_path.dentry);
41454129

41464130
if (IS_ERR(dent)) {
41474131
ksmbd_debug(SMB, "Cannot lookup `%s' [%ld]\n",

0 commit comments

Comments
 (0)