Message ID | 20180808050749.26562-4-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 | 48 ++++++++++++++++++++++++++++++++++-------------- > fs/cifs/smb2proto.h | 3 +++ > 2 files changed, 37 insertions(+), 14 deletions(-) > > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c > index 912648fe5cdb..575293fe4b28 100644 > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -2448,43 +2448,62 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon, > } > > int > +SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, > + u64 persistent_fid, u64 volatile_fid) > +{ > + struct smb2_close_req *req; > + struct kvec *iov = rqst->rq_iov; > + unsigned int total_len; > + int rc; > + > + rc = smb2_plain_req_init(SMB2_CLOSE, tcon, (void **) &req, &total_len); > + if (rc) > + return rc; > + > + req->PersistentFileId = persistent_fid; > + req->VolatileFileId = volatile_fid; > + > + iov[0].iov_base = (char *)req; > + iov[0].iov_len = total_len; > + > + return 0; > +} > + > +void > +SMB2_close_free(struct smb_rqst *rqst) { > + cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */ > +} > + > +int > SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, > u64 persistent_fid, u64 volatile_fid, int flags) > { > struct smb_rqst rqst; > - struct smb2_close_req *req; > - struct smb2_close_rsp *rsp; > + struct smb2_close_rsp *rsp = NULL; > struct cifs_ses *ses = tcon->ses; > struct kvec iov[1]; > struct kvec rsp_iov; > int resp_buftype; > int rc = 0; > - unsigned int total_len; > > cifs_dbg(FYI, "Close\n"); > > if (!ses || !(ses->server)) > return -EIO; > > - rc = smb2_plain_req_init(SMB2_CLOSE, tcon, (void **) &req, &total_len); > - if (rc) > - return rc; > - > if (smb3_encryption_required(tcon)) > flags |= CIFS_TRANSFORM_REQ; > > - req->PersistentFileId = persistent_fid; > - req->VolatileFileId = volatile_fid; > - > - iov[0].iov_base = (char *)req; > - iov[0].iov_len = total_len; > - > memset(&rqst, 0, sizeof(struct smb_rqst)); > + memset(&iov, 0, sizeof(iov)); > rqst.rq_iov = iov; > rqst.rq_nvec = 1; > > + rc = SMB2_close_init(tcon, &rqst, persistent_fid, volatile_fid); > + if (rc) > + goto close_exit; > + > rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); > - cifs_small_buf_release(req); > rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; > > if (rc != 0) { > @@ -2497,6 +2516,7 @@ SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, > /* BB FIXME - decode close response, update inode for caching */ > > close_exit: > + SMB2_close_free(&rqst); > free_rsp_buf(resp_buftype, rsp); > return rc; > } > diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h > index a344a3212ce4..b81220fd9bf5 100644 > --- a/fs/cifs/smb2proto.h > +++ b/fs/cifs/smb2proto.h > @@ -145,6 +145,9 @@ extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, > u64 persistent_file_id, u64 volatile_file_id); > extern int SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, > u64 persistent_fid, u64 volatile_fid, int flags); > +extern int SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, > + u64 persistent_file_id, u64 volatile_file_id); > +extern void SMB2_close_free(struct smb_rqst *rqst); > extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, > u64 persistent_file_id, u64 volatile_file_id); > extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, > -- > 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 912648fe5cdb..575293fe4b28 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2448,43 +2448,62 @@ SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon, } int +SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, + u64 persistent_fid, u64 volatile_fid) +{ + struct smb2_close_req *req; + struct kvec *iov = rqst->rq_iov; + unsigned int total_len; + int rc; + + rc = smb2_plain_req_init(SMB2_CLOSE, tcon, (void **) &req, &total_len); + if (rc) + return rc; + + req->PersistentFileId = persistent_fid; + req->VolatileFileId = volatile_fid; + + iov[0].iov_base = (char *)req; + iov[0].iov_len = total_len; + + return 0; +} + +void +SMB2_close_free(struct smb_rqst *rqst) { + cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */ +} + +int SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, int flags) { struct smb_rqst rqst; - struct smb2_close_req *req; - struct smb2_close_rsp *rsp; + struct smb2_close_rsp *rsp = NULL; struct cifs_ses *ses = tcon->ses; struct kvec iov[1]; struct kvec rsp_iov; int resp_buftype; int rc = 0; - unsigned int total_len; cifs_dbg(FYI, "Close\n"); if (!ses || !(ses->server)) return -EIO; - rc = smb2_plain_req_init(SMB2_CLOSE, tcon, (void **) &req, &total_len); - if (rc) - return rc; - if (smb3_encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; - req->PersistentFileId = persistent_fid; - req->VolatileFileId = volatile_fid; - - iov[0].iov_base = (char *)req; - iov[0].iov_len = total_len; - memset(&rqst, 0, sizeof(struct smb_rqst)); + memset(&iov, 0, sizeof(iov)); rqst.rq_iov = iov; rqst.rq_nvec = 1; + rc = SMB2_close_init(tcon, &rqst, persistent_fid, volatile_fid); + if (rc) + goto close_exit; + rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov); - cifs_small_buf_release(req); rsp = (struct smb2_close_rsp *)rsp_iov.iov_base; if (rc != 0) { @@ -2497,6 +2516,7 @@ SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, /* BB FIXME - decode close response, update inode for caching */ close_exit: + SMB2_close_free(&rqst); free_rsp_buf(resp_buftype, rsp); return rc; } diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index a344a3212ce4..b81220fd9bf5 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h @@ -145,6 +145,9 @@ extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id); extern int SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, int flags); +extern int SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, + u64 persistent_file_id, u64 volatile_file_id); +extern void SMB2_close_free(struct smb_rqst *rqst); extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id); extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> --- fs/cifs/smb2pdu.c | 48 ++++++++++++++++++++++++++++++++++-------------- fs/cifs/smb2proto.h | 3 +++ 2 files changed, 37 insertions(+), 14 deletions(-)