Skip to content

Commit 17661ec

Browse files
namjaejeonsmfrench
authored andcommitted
ksmbd: don't remove dos attribute xattr on O_TRUNC open
When smb client open file in ksmbd share with O_TRUNC, dos attribute xattr is removed as well as data in file. This cause the FSCTL_SET_SPARSE request from the client fails because ksmbd can't update the dos attribute after setting ATTR_SPARSE_FILE. And this patch fix xfstests generic/469 test also. Signed-off-by: Namjae Jeon <[email protected]> Reviewed-by: Hyunchul Lee <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent c90b31e commit 17661ec

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2330,15 +2330,15 @@ static int smb2_remove_smb_xattrs(struct path *path)
23302330
name += strlen(name) + 1) {
23312331
ksmbd_debug(SMB, "%s, len %zd\n", name, strlen(name));
23322332

2333-
if (strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
2334-
strncmp(&name[XATTR_USER_PREFIX_LEN], DOS_ATTRIBUTE_PREFIX,
2335-
DOS_ATTRIBUTE_PREFIX_LEN) &&
2336-
strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX, STREAM_PREFIX_LEN))
2337-
continue;
2338-
2339-
err = ksmbd_vfs_remove_xattr(user_ns, path->dentry, name);
2340-
if (err)
2341-
ksmbd_debug(SMB, "remove xattr failed : %s\n", name);
2333+
if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN) &&
2334+
!strncmp(&name[XATTR_USER_PREFIX_LEN], STREAM_PREFIX,
2335+
STREAM_PREFIX_LEN)) {
2336+
err = ksmbd_vfs_remove_xattr(user_ns, path->dentry,
2337+
name);
2338+
if (err)
2339+
ksmbd_debug(SMB, "remove xattr failed : %s\n",
2340+
name);
2341+
}
23422342
}
23432343
out:
23442344
kvfree(xattr_list);

0 commit comments

Comments
 (0)