ksmbd: fix rename failure
authorNamjae Jeon <linkinjeon@kernel.org>
Wed, 21 May 2025 08:07:36 +0000 (17:07 +0900)
committerSteve French <stfrench@microsoft.com>
Thu, 22 May 2025 03:30:30 +0000 (22:30 -0500)
I found that rename fails after cifs mount due to update of
lookup_one_qstr_excl().

 mv a/c b/
mv: cannot move 'a/c' to 'b/c': No such file or directory

In order to rename to a new name regardless of whether the dentry is
negative, we need to get the dentry through lookup_one_qstr_excl().
So It will not return error if the name doesn't exist.

Fixes: 204a575e91f3 ("VFS: add common error checks to lookup_one_qstr_excl()")
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/vfs.c

index 156ded9ac889bd89b71ae321715b18f1c7a9f7ef..baf0d3031a44a0b5c46f1c4ad69fe3e02269387b 100644 (file)
@@ -682,7 +682,7 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,
        struct ksmbd_file *parent_fp;
        int new_type;
        int err, lookup_flags = LOOKUP_NO_SYMLINKS;
-       int target_lookup_flags = LOOKUP_RENAME_TARGET;
+       int target_lookup_flags = LOOKUP_RENAME_TARGET | LOOKUP_CREATE;
 
        if (ksmbd_override_fsids(work))
                return -ENOMEM;