aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilov@microsoft.com>2016-11-23 18:08:14 -0500
committerSteve French <smfrench@gmail.com>2017-02-01 17:46:35 -0500
commitfb2036d817584df42504910fe104f68517e8990e (patch)
treeb5a06b7a0eea206f04884fcff2873c22237d3969
parentda502f7df03d2d0b416775f92ae022f3f82bedd5 (diff)
CIFS: Make send_cancel take rqst as argument
Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com>
-rw-r--r--fs/cifs/cifsglob.h2
-rw-r--r--fs/cifs/smb1ops.c4
-rw-r--r--fs/cifs/transport.c33
3 files changed, 22 insertions, 17 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 7ea8a3393936..6d5fc87ba335 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -208,7 +208,7 @@ struct cifsInodeInfo;
208struct cifs_open_parms; 208struct cifs_open_parms;
209 209
210struct smb_version_operations { 210struct smb_version_operations {
211 int (*send_cancel)(struct TCP_Server_Info *, void *, 211 int (*send_cancel)(struct TCP_Server_Info *, struct smb_rqst *,
212 struct mid_q_entry *); 212 struct mid_q_entry *);
213 bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *); 213 bool (*compare_fids)(struct cifsFileInfo *, struct cifsFileInfo *);
214 /* setup request: allocate mid, sign message */ 214 /* setup request: allocate mid, sign message */
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index fc537c29044e..67a987e4d026 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -36,11 +36,11 @@
36 * SMB_COM_NT_CANCEL request and then sends it. 36 * SMB_COM_NT_CANCEL request and then sends it.
37 */ 37 */
38static int 38static int
39send_nt_cancel(struct TCP_Server_Info *server, void *buf, 39send_nt_cancel(struct TCP_Server_Info *server, struct smb_rqst *rqst,
40 struct mid_q_entry *mid) 40 struct mid_q_entry *mid)
41{ 41{
42 int rc = 0; 42 int rc = 0;
43 struct smb_hdr *in_buf = (struct smb_hdr *)buf; 43 struct smb_hdr *in_buf = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
44 44
45 /* -4 for RFC1001 length and +2 for BCC field */ 45 /* -4 for RFC1001 length and +2 for BCC field */
46 in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2); 46 in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2);
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 40150fe0c16a..878f0dceeb13 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -596,10 +596,11 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
596} 596}
597 597
598static inline int 598static inline int
599send_cancel(struct TCP_Server_Info *server, void *buf, struct mid_q_entry *mid) 599send_cancel(struct TCP_Server_Info *server, struct smb_rqst *rqst,
600 struct mid_q_entry *mid)
600{ 601{
601 return server->ops->send_cancel ? 602 return server->ops->send_cancel ?
602 server->ops->send_cancel(server, buf, mid) : 0; 603 server->ops->send_cancel(server, rqst, mid) : 0;
603} 604}
604 605
605int 606int
@@ -719,7 +720,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
719 720
720 rc = wait_for_response(ses->server, midQ); 721 rc = wait_for_response(ses->server, midQ);
721 if (rc != 0) { 722 if (rc != 0) {
722 send_cancel(ses->server, buf, midQ); 723 send_cancel(ses->server, &rqst, midQ);
723 spin_lock(&GlobalMid_Lock); 724 spin_lock(&GlobalMid_Lock);
724 if (midQ->mid_state == MID_REQUEST_SUBMITTED) { 725 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
725 midQ->callback = DeleteMidQEntry; 726 midQ->callback = DeleteMidQEntry;
@@ -772,6 +773,9 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
772{ 773{
773 int rc = 0; 774 int rc = 0;
774 struct mid_q_entry *midQ; 775 struct mid_q_entry *midQ;
776 unsigned int len = be32_to_cpu(in_buf->smb_buf_length);
777 struct kvec iov = { .iov_base = in_buf, .iov_len = len };
778 struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
775 779
776 if (ses == NULL) { 780 if (ses == NULL) {
777 cifs_dbg(VFS, "Null smb session\n"); 781 cifs_dbg(VFS, "Null smb session\n");
@@ -789,10 +793,9 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
789 to the same server. We may make this configurable later or 793 to the same server. We may make this configurable later or
790 use ses->maxReq */ 794 use ses->maxReq */
791 795
792 if (be32_to_cpu(in_buf->smb_buf_length) > CIFSMaxBufSize + 796 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
793 MAX_CIFS_HDR_SIZE - 4) {
794 cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", 797 cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
795 be32_to_cpu(in_buf->smb_buf_length)); 798 len);
796 return -EIO; 799 return -EIO;
797 } 800 }
798 801
@@ -823,7 +826,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
823 midQ->mid_state = MID_REQUEST_SUBMITTED; 826 midQ->mid_state = MID_REQUEST_SUBMITTED;
824 827
825 cifs_in_send_inc(ses->server); 828 cifs_in_send_inc(ses->server);
826 rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); 829 rc = smb_send(ses->server, in_buf, len);
827 cifs_in_send_dec(ses->server); 830 cifs_in_send_dec(ses->server);
828 cifs_save_when_sent(midQ); 831 cifs_save_when_sent(midQ);
829 832
@@ -840,7 +843,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
840 843
841 rc = wait_for_response(ses->server, midQ); 844 rc = wait_for_response(ses->server, midQ);
842 if (rc != 0) { 845 if (rc != 0) {
843 send_cancel(ses->server, in_buf, midQ); 846 send_cancel(ses->server, &rqst, midQ);
844 spin_lock(&GlobalMid_Lock); 847 spin_lock(&GlobalMid_Lock);
845 if (midQ->mid_state == MID_REQUEST_SUBMITTED) { 848 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
846 /* no longer considered to be "in-flight" */ 849 /* no longer considered to be "in-flight" */
@@ -909,6 +912,9 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
909 int rstart = 0; 912 int rstart = 0;
910 struct mid_q_entry *midQ; 913 struct mid_q_entry *midQ;
911 struct cifs_ses *ses; 914 struct cifs_ses *ses;
915 unsigned int len = be32_to_cpu(in_buf->smb_buf_length);
916 struct kvec iov = { .iov_base = in_buf, .iov_len = len };
917 struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
912 918
913 if (tcon == NULL || tcon->ses == NULL) { 919 if (tcon == NULL || tcon->ses == NULL) {
914 cifs_dbg(VFS, "Null smb session\n"); 920 cifs_dbg(VFS, "Null smb session\n");
@@ -928,10 +934,9 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
928 to the same server. We may make this configurable later or 934 to the same server. We may make this configurable later or
929 use ses->maxReq */ 935 use ses->maxReq */
930 936
931 if (be32_to_cpu(in_buf->smb_buf_length) > CIFSMaxBufSize + 937 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
932 MAX_CIFS_HDR_SIZE - 4) {
933 cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n", 938 cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
934 be32_to_cpu(in_buf->smb_buf_length)); 939 len);
935 return -EIO; 940 return -EIO;
936 } 941 }
937 942
@@ -960,7 +965,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
960 965
961 midQ->mid_state = MID_REQUEST_SUBMITTED; 966 midQ->mid_state = MID_REQUEST_SUBMITTED;
962 cifs_in_send_inc(ses->server); 967 cifs_in_send_inc(ses->server);
963 rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); 968 rc = smb_send(ses->server, in_buf, len);
964 cifs_in_send_dec(ses->server); 969 cifs_in_send_dec(ses->server);
965 cifs_save_when_sent(midQ); 970 cifs_save_when_sent(midQ);
966 971
@@ -989,7 +994,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
989 if (in_buf->Command == SMB_COM_TRANSACTION2) { 994 if (in_buf->Command == SMB_COM_TRANSACTION2) {
990 /* POSIX lock. We send a NT_CANCEL SMB to cause the 995 /* POSIX lock. We send a NT_CANCEL SMB to cause the
991 blocking lock to return. */ 996 blocking lock to return. */
992 rc = send_cancel(ses->server, in_buf, midQ); 997 rc = send_cancel(ses->server, &rqst, midQ);
993 if (rc) { 998 if (rc) {
994 cifs_delete_mid(midQ); 999 cifs_delete_mid(midQ);
995 return rc; 1000 return rc;
@@ -1010,7 +1015,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
1010 1015
1011 rc = wait_for_response(ses->server, midQ); 1016 rc = wait_for_response(ses->server, midQ);
1012 if (rc) { 1017 if (rc) {
1013 send_cancel(ses->server, in_buf, midQ); 1018 send_cancel(ses->server, &rqst, midQ);
1014 spin_lock(&GlobalMid_Lock); 1019 spin_lock(&GlobalMid_Lock);
1015 if (midQ->mid_state == MID_REQUEST_SUBMITTED) { 1020 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
1016 /* no longer considered to be "in-flight" */ 1021 /* no longer considered to be "in-flight" */