Commit 0967e545 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: use a compound for setting an xattr

Improve performance by reducing number of network round trips
for set xattr.
Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 5890255b
...@@ -907,14 +907,28 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -907,14 +907,28 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
const __u16 ea_value_len, const struct nls_table *nls_codepage, const __u16 ea_value_len, const struct nls_table *nls_codepage,
struct cifs_sb_info *cifs_sb) struct cifs_sb_info *cifs_sb)
{ {
int rc; struct cifs_ses *ses = tcon->ses;
__le16 *utf16_path; struct TCP_Server_Info *server = ses->server;
__u8 oplock = SMB2_OPLOCK_LEVEL_NONE; __le16 *utf16_path = NULL;
struct cifs_open_parms oparms;
struct cifs_fid fid;
struct smb2_file_full_ea_info *ea;
int ea_name_len = strlen(ea_name); int ea_name_len = strlen(ea_name);
int flags = 0;
int len; int len;
struct smb_rqst rqst[3];
int resp_buftype[3];
struct kvec rsp_iov[3];
struct kvec open_iov[SMB2_CREATE_IOV_SIZE];
struct cifs_open_parms oparms;
__u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
struct cifs_fid fid;
struct kvec si_iov[SMB2_SET_INFO_IOV_SIZE];
unsigned int size[1];
void *data[1];
struct smb2_file_full_ea_info *ea = NULL;
struct kvec close_iov[1];
int rc;
if (smb3_encryption_required(tcon))
flags |= CIFS_TRANSFORM_REQ;
if (ea_name_len > 255) if (ea_name_len > 255)
return -EINVAL; return -EINVAL;
...@@ -923,6 +937,16 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -923,6 +937,16 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
if (!utf16_path) if (!utf16_path)
return -ENOMEM; return -ENOMEM;
memset(rqst, 0, sizeof(rqst));
resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
memset(rsp_iov, 0, sizeof(rsp_iov));
/* Open */
memset(&open_iov, 0, sizeof(open_iov));
rqst[0].rq_iov = open_iov;
rqst[0].rq_nvec = SMB2_CREATE_IOV_SIZE;
memset(&oparms, 0, sizeof(oparms));
oparms.tcon = tcon; oparms.tcon = tcon;
oparms.desired_access = FILE_WRITE_EA; oparms.desired_access = FILE_WRITE_EA;
oparms.disposition = FILE_OPEN; oparms.disposition = FILE_OPEN;
...@@ -933,18 +957,22 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -933,18 +957,22 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
oparms.fid = &fid; oparms.fid = &fid;
oparms.reconnect = false; oparms.reconnect = false;
rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL, NULL); rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, utf16_path);
kfree(utf16_path); if (rc)
if (rc) { goto sea_exit;
cifs_dbg(FYI, "open failed rc=%d\n", rc); smb2_set_next_command(ses->server, &rqst[0]);
return rc;
}
/* Set Info */
memset(&si_iov, 0, sizeof(si_iov));
rqst[1].rq_iov = si_iov;
rqst[1].rq_nvec = 1;
len = sizeof(ea) + ea_name_len + ea_value_len + 1; len = sizeof(ea) + ea_name_len + ea_value_len + 1;
ea = kzalloc(len, GFP_KERNEL); ea = kzalloc(len, GFP_KERNEL);
if (ea == NULL) { if (ea == NULL) {
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); rc = -ENOMEM;
return -ENOMEM; goto sea_exit;
} }
ea->ea_name_length = ea_name_len; ea->ea_name_length = ea_name_len;
...@@ -952,12 +980,36 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -952,12 +980,36 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
memcpy(ea->ea_data, ea_name, ea_name_len + 1); memcpy(ea->ea_data, ea_name, ea_name_len + 1);
memcpy(ea->ea_data + ea_name_len + 1, ea_value, ea_value_len); memcpy(ea->ea_data + ea_name_len + 1, ea_value, ea_value_len);
rc = SMB2_set_ea(xid, tcon, fid.persistent_fid, fid.volatile_fid, ea, size[0] = len;
len); data[0] = ea;
kfree(ea);
SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); rc = SMB2_set_info_init(tcon, &rqst[1], COMPOUND_FID,
COMPOUND_FID, current->tgid,
FILE_FULL_EA_INFORMATION,
SMB2_O_INFO_FILE, 0, data, size);
smb2_set_next_command(server, &rqst[1]);
smb2_set_related(&rqst[1]);
/* Close */
memset(&close_iov, 0, sizeof(close_iov));
rqst[2].rq_iov = close_iov;
rqst[2].rq_nvec = 1;
rc = SMB2_close_init(tcon, &rqst[2], COMPOUND_FID, COMPOUND_FID);
smb2_set_related(&rqst[2]);
rc = compound_send_recv(xid, ses, flags, 3, rqst,
resp_buftype, rsp_iov);
sea_exit:
kfree(ea);
kfree(utf16_path);
SMB2_open_free(&rqst[0]);
SMB2_set_info_free(&rqst[1]);
SMB2_close_free(&rqst[2]);
free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);
free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);
return rc; return rc;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment