提交 dc9300a6 编写于 作者: R Ronnie Sahlberg 提交者: Steve French

cifs: use existing handle for compound_op(OP_SET_INFO) when possible

If we already have a writable handle for a path we want to set the
attributes for then use that instead of a create/set-info/close compound.
Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: NSteve French <stfrench@microsoft.com>
上级 8de9e86c
...@@ -192,14 +192,27 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -192,14 +192,27 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
size[0] = sizeof(FILE_BASIC_INFO); size[0] = sizeof(FILE_BASIC_INFO);
data[0] = ptr; data[0] = ptr;
rc = SMB2_set_info_init(tcon, &rqst[num_rqst], COMPOUND_FID, if (cfile)
COMPOUND_FID, current->tgid, rc = SMB2_set_info_init(tcon, &rqst[num_rqst],
FILE_BASIC_INFORMATION, cfile->fid.persistent_fid,
SMB2_O_INFO_FILE, 0, data, size); cfile->fid.volatile_fid, current->tgid,
FILE_BASIC_INFORMATION,
SMB2_O_INFO_FILE, 0, data, size);
else {
rc = SMB2_set_info_init(tcon, &rqst[num_rqst],
COMPOUND_FID,
COMPOUND_FID, current->tgid,
FILE_BASIC_INFORMATION,
SMB2_O_INFO_FILE, 0, data, size);
if (!rc) {
smb2_set_next_command(tcon, &rqst[num_rqst]);
smb2_set_related(&rqst[num_rqst]);
}
}
if (rc) if (rc)
goto finished; goto finished;
smb2_set_next_command(tcon, &rqst[num_rqst]); num_rqst++;
smb2_set_related(&rqst[num_rqst++]);
trace_smb3_set_info_compound_enter(xid, ses->Suid, tcon->tid, trace_smb3_set_info_compound_enter(xid, ses->Suid, tcon->tid,
full_path); full_path);
break; break;
...@@ -231,8 +244,10 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -231,8 +244,10 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
COMPOUND_FID, COMPOUND_FID, COMPOUND_FID, COMPOUND_FID,
current->tgid, FILE_RENAME_INFORMATION, current->tgid, FILE_RENAME_INFORMATION,
SMB2_O_INFO_FILE, 0, data, size); SMB2_O_INFO_FILE, 0, data, size);
smb2_set_next_command(tcon, &rqst[num_rqst]); if (!rc) {
smb2_set_related(&rqst[num_rqst]); smb2_set_next_command(tcon, &rqst[num_rqst]);
smb2_set_related(&rqst[num_rqst]);
}
} }
if (rc) if (rc)
goto finished; goto finished;
...@@ -475,6 +490,7 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name, ...@@ -475,6 +490,7 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name,
{ {
FILE_BASIC_INFO data; FILE_BASIC_INFO data;
struct cifsInodeInfo *cifs_i; struct cifsInodeInfo *cifs_i;
struct cifsFileInfo *cfile;
u32 dosattrs; u32 dosattrs;
int tmprc; int tmprc;
...@@ -482,10 +498,11 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name, ...@@ -482,10 +498,11 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name,
cifs_i = CIFS_I(inode); cifs_i = CIFS_I(inode);
dosattrs = cifs_i->cifsAttrs | ATTR_READONLY; dosattrs = cifs_i->cifsAttrs | ATTR_READONLY;
data.Attributes = cpu_to_le32(dosattrs); data.Attributes = cpu_to_le32(dosattrs);
cifs_get_writable_path(tcon, name, &cfile);
tmprc = smb2_compound_op(xid, tcon, cifs_sb, name, tmprc = smb2_compound_op(xid, tcon, cifs_sb, name,
FILE_WRITE_ATTRIBUTES, FILE_CREATE, FILE_WRITE_ATTRIBUTES, FILE_CREATE,
CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO, CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO,
NULL); cfile);
if (tmprc == 0) if (tmprc == 0)
cifs_i->cifsAttrs = dosattrs; cifs_i->cifsAttrs = dosattrs;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册