Message ID | 20180808050749.26562-5-lsahlber@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | cifs: compounding | expand |
2018-08-07 22:07 GMT-07:00 Ronnie Sahlberg <lsahlber@redhat.com>: > Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> > --- > fs/cifs/smb2pdu.c | 68 ++++++++++++++++++++++++++++++++++++----------------- > fs/cifs/smb2proto.h | 5 ++++ > 2 files changed, 51 insertions(+), 22 deletions(-) > > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c > index 575293fe4b28..0b0c22fafb03 100644 > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -2583,36 +2583,22 @@ validate_and_copy_iov(unsigned int offset, unsigned int buffer_length, > return 0; > } > > -static int > -query_info(const unsigned int xid, struct cifs_tcon *tcon, > - u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type, > - u32 additional_info, size_t output_len, size_t min_len, void **data, > - u32 *dlen) > +int > +SMB2_query_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, > + u64 persistent_fid, u64 volatile_fid, > + u8 info_class, u8 info_type, u32 additional_info, > + size_t output_len) > { > - struct smb_rqst rqst; > struct smb2_query_info_req *req; > - struct smb2_query_info_rsp *rsp = NULL; > - struct kvec iov[2]; > - struct kvec rsp_iov; > - int rc = 0; > - int resp_buftype; > - struct cifs_ses *ses = tcon->ses; > - int flags = 0; > + struct kvec *iov = rqst->rq_iov; > unsigned int total_len; > - > - cifs_dbg(FYI, "Query Info\n"); > - > - if (!ses || !(ses->server)) > - return -EIO; > + int rc; > > rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, (void **) &req, > &total_len); > if (rc) > return rc; > > - if (smb3_encryption_required(tcon)) > - flags |= CIFS_TRANSFORM_REQ; > - > req->InfoType = info_type; > req->FileInfoClass = info_class; > req->PersistentFileId = persistent_fid; > @@ -2629,13 +2615,50 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, > iov[0].iov_base = (char *)req; > /* 1 for Buffer */ > iov[0].iov_len = total_len - 1; > + return 0; > +} > + > +void > +SMB2_query_info_free(struct smb_rqst *rqst) { > + cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */ > +} > + > + > +static int > +query_info(const unsigned int xid, struct cifs_tcon *tcon, > + u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type, > + u32 additional_info, size_t output_len, size_t min_len, void **data, > + u32 *dlen) > +{ > + struct smb_rqst rqst; > + struct smb2_query_info_rsp *rsp = NULL; > + struct kvec iov[1]; > + struct kvec rsp_iov; > + int rc = 0; > + int resp_buftype; > + struct cifs_ses *ses = tcon->ses; > + int flags = 0; > + > + cifs_dbg(FYI, "Query Info\n"); > + > + if (!ses || !(ses->server)) > + return -EIO; > + > + if (smb3_encryption_required(tcon)) > + flags |= CIFS_TRANSFORM_REQ; > > memset(&rqst, 0, sizeof(struct smb_rqst)); > + memset(&iov, 0, sizeof(iov)); > rqst.rq_iov = iov; > rqst.rq_nvec = 1; > > + rc = SMB2_query_info_init(tcon, &rqst, persistent_fid, volatile_fid, > + info_class, info_type, additional_info, > + output_len); > + if (rc) > + goto qinf_exit; > + > rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); > - cifs_small_buf_release(req); > rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; > > if (rc) { > @@ -2664,6 +2687,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, > &rsp_iov, min_len, *data); > > qinf_exit: > + SMB2_query_info_free(&rqst); > free_rsp_buf(resp_buftype, rsp); > return rc; > } > diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h > index b81220fd9bf5..57bdd2711974 100644 > --- a/fs/cifs/smb2proto.h > +++ b/fs/cifs/smb2proto.h > @@ -157,6 +157,11 @@ extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, > extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon, > u64 persistent_file_id, u64 volatile_file_id, > struct smb2_file_all_info *data); > +extern int SMB2_query_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, > + u64 persistent_fid, u64 volatile_fid, > + u8 info_class, u8 info_type, > + u32 additional_info, size_t output_len); > +extern void SMB2_query_info_free(struct smb_rqst *rqst); > extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon, > u64 persistent_file_id, u64 volatile_file_id, > void **data, unsigned int *plen); > -- > 2.13.3 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com> -- Best regards, Pavel Shilovsky -- To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 575293fe4b28..0b0c22fafb03 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2583,36 +2583,22 @@ validate_and_copy_iov(unsigned int offset, unsigned int buffer_length, return 0; } -static int -query_info(const unsigned int xid, struct cifs_tcon *tcon, - u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type, - u32 additional_info, size_t output_len, size_t min_len, void **data, - u32 *dlen) +int +SMB2_query_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, + u64 persistent_fid, u64 volatile_fid, + u8 info_class, u8 info_type, u32 additional_info, + size_t output_len) { - struct smb_rqst rqst; struct smb2_query_info_req *req; - struct smb2_query_info_rsp *rsp = NULL; - struct kvec iov[2]; - struct kvec rsp_iov; - int rc = 0; - int resp_buftype; - struct cifs_ses *ses = tcon->ses; - int flags = 0; + struct kvec *iov = rqst->rq_iov; unsigned int total_len; - - cifs_dbg(FYI, "Query Info\n"); - - if (!ses || !(ses->server)) - return -EIO; + int rc; rc = smb2_plain_req_init(SMB2_QUERY_INFO, tcon, (void **) &req, &total_len); if (rc) return rc; - if (smb3_encryption_required(tcon)) - flags |= CIFS_TRANSFORM_REQ; - req->InfoType = info_type; req->FileInfoClass = info_class; req->PersistentFileId = persistent_fid; @@ -2629,13 +2615,50 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, iov[0].iov_base = (char *)req; /* 1 for Buffer */ iov[0].iov_len = total_len - 1; + return 0; +} + +void +SMB2_query_info_free(struct smb_rqst *rqst) { + cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */ +} + + +static int +query_info(const unsigned int xid, struct cifs_tcon *tcon, + u64 persistent_fid, u64 volatile_fid, u8 info_class, u8 info_type, + u32 additional_info, size_t output_len, size_t min_len, void **data, + u32 *dlen) +{ + struct smb_rqst rqst; + struct smb2_query_info_rsp *rsp = NULL; + struct kvec iov[1]; + struct kvec rsp_iov; + int rc = 0; + int resp_buftype; + struct cifs_ses *ses = tcon->ses; + int flags = 0; + + cifs_dbg(FYI, "Query Info\n"); + + if (!ses || !(ses->server)) + return -EIO; + + if (smb3_encryption_required(tcon)) + flags |= CIFS_TRANSFORM_REQ; memset(&rqst, 0, sizeof(struct smb_rqst)); + memset(&iov, 0, sizeof(iov)); rqst.rq_iov = iov; rqst.rq_nvec = 1; + rc = SMB2_query_info_init(tcon, &rqst, persistent_fid, volatile_fid, + info_class, info_type, additional_info, + output_len); + if (rc) + goto qinf_exit; + rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); - cifs_small_buf_release(req); rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; if (rc) { @@ -2664,6 +2687,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, &rsp_iov, min_len, *data); qinf_exit: + SMB2_query_info_free(&rqst); free_rsp_buf(resp_buftype, rsp); return rc; } diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index b81220fd9bf5..57bdd2711974 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h @@ -157,6 +157,11 @@ extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id, struct smb2_file_all_info *data); +extern int SMB2_query_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, + u64 persistent_fid, u64 volatile_fid, + u8 info_class, u8 info_type, + u32 additional_info, size_t output_len); +extern void SMB2_query_info_free(struct smb_rqst *rqst); extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id, void **data, unsigned int *plen);
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> --- fs/cifs/smb2pdu.c | 68 ++++++++++++++++++++++++++++++++++++----------------- fs/cifs/smb2proto.h | 5 ++++ 2 files changed, 51 insertions(+), 22 deletions(-)