diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-05-15 12:21:10 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2012-05-16 21:13:34 -0400 |
commit | 121b046af54437b084aa0e4be967ae5aed7528b5 (patch) | |
tree | 68acfdb619d160a6b8d6dc03c3c0017b43616961 /fs/cifs | |
parent | 23db65f511e6ee98ad767833f2ec58b0568ba32b (diff) |
cifs: convert send_nt_cancel into a version specific op
For SMB2, this should be a no-op. Obviously if we wanted to do something
for the SMB2 case, we could also define an operation here for it.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsglob.h | 6 | ||||
-rw-r--r-- | fs/cifs/smb1ops.c | 41 | ||||
-rw-r--r-- | fs/cifs/transport.c | 46 |
3 files changed, 54 insertions, 39 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 812e22ab0a49..c41bf6d166e3 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -154,7 +154,12 @@ enum smb_version { | |||
154 | Smb_1 = 1, | 154 | Smb_1 = 1, |
155 | }; | 155 | }; |
156 | 156 | ||
157 | struct mid_q_entry; | ||
158 | struct TCP_Server_Info; | ||
159 | |||
157 | struct smb_version_operations { | 160 | struct smb_version_operations { |
161 | int (*send_cancel)(struct TCP_Server_Info *, void *, | ||
162 | struct mid_q_entry *); | ||
158 | }; | 163 | }; |
159 | 164 | ||
160 | struct smb_version_values { | 165 | struct smb_version_values { |
@@ -718,7 +723,6 @@ static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon, | |||
718 | 723 | ||
719 | #endif | 724 | #endif |
720 | 725 | ||
721 | struct mid_q_entry; | ||
722 | 726 | ||
723 | /* | 727 | /* |
724 | * This is the prototype for the mid receive function. This function is for | 728 | * This is the prototype for the mid receive function. This function is for |
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index d2850d194eb5..fa486f0ca8b2 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c | |||
@@ -18,8 +18,49 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "cifsglob.h" | 20 | #include "cifsglob.h" |
21 | #include "cifsproto.h" | ||
22 | #include "cifs_debug.h" | ||
23 | |||
24 | /* | ||
25 | * An NT cancel request header looks just like the original request except: | ||
26 | * | ||
27 | * The Command is SMB_COM_NT_CANCEL | ||
28 | * The WordCount is zeroed out | ||
29 | * The ByteCount is zeroed out | ||
30 | * | ||
31 | * This function mangles an existing request buffer into a | ||
32 | * SMB_COM_NT_CANCEL request and then sends it. | ||
33 | */ | ||
34 | static int | ||
35 | send_nt_cancel(struct TCP_Server_Info *server, void *buf, | ||
36 | struct mid_q_entry *mid) | ||
37 | { | ||
38 | int rc = 0; | ||
39 | struct smb_hdr *in_buf = (struct smb_hdr *)buf; | ||
40 | |||
41 | /* -4 for RFC1001 length and +2 for BCC field */ | ||
42 | in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2); | ||
43 | in_buf->Command = SMB_COM_NT_CANCEL; | ||
44 | in_buf->WordCount = 0; | ||
45 | put_bcc(0, in_buf); | ||
46 | |||
47 | mutex_lock(&server->srv_mutex); | ||
48 | rc = cifs_sign_smb(in_buf, server, &mid->sequence_number); | ||
49 | if (rc) { | ||
50 | mutex_unlock(&server->srv_mutex); | ||
51 | return rc; | ||
52 | } | ||
53 | rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); | ||
54 | mutex_unlock(&server->srv_mutex); | ||
55 | |||
56 | cFYI(1, "issued NT_CANCEL for mid %u, rc = %d", | ||
57 | in_buf->Mid, rc); | ||
58 | |||
59 | return rc; | ||
60 | } | ||
21 | 61 | ||
22 | struct smb_version_operations smb1_operations = { | 62 | struct smb_version_operations smb1_operations = { |
63 | .send_cancel = send_nt_cancel, | ||
23 | }; | 64 | }; |
24 | 65 | ||
25 | struct smb_version_values smb1_values = { | 66 | struct smb_version_values smb1_values = { |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 0961336513d5..269a5a7e0030 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -483,41 +483,11 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server) | |||
483 | return rc; | 483 | return rc; |
484 | } | 484 | } |
485 | 485 | ||
486 | /* | 486 | static inline int |
487 | * An NT cancel request header looks just like the original request except: | 487 | send_cancel(struct TCP_Server_Info *server, void *buf, struct mid_q_entry *mid) |
488 | * | ||
489 | * The Command is SMB_COM_NT_CANCEL | ||
490 | * The WordCount is zeroed out | ||
491 | * The ByteCount is zeroed out | ||
492 | * | ||
493 | * This function mangles an existing request buffer into a | ||
494 | * SMB_COM_NT_CANCEL request and then sends it. | ||
495 | */ | ||
496 | static int | ||
497 | send_nt_cancel(struct TCP_Server_Info *server, struct smb_hdr *in_buf, | ||
498 | struct mid_q_entry *mid) | ||
499 | { | 488 | { |
500 | int rc = 0; | 489 | return server->ops->send_cancel ? |
501 | 490 | server->ops->send_cancel(server, buf, mid) : 0; | |
502 | /* -4 for RFC1001 length and +2 for BCC field */ | ||
503 | in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2); | ||
504 | in_buf->Command = SMB_COM_NT_CANCEL; | ||
505 | in_buf->WordCount = 0; | ||
506 | put_bcc(0, in_buf); | ||
507 | |||
508 | mutex_lock(&server->srv_mutex); | ||
509 | rc = cifs_sign_smb(in_buf, server, &mid->sequence_number); | ||
510 | if (rc) { | ||
511 | mutex_unlock(&server->srv_mutex); | ||
512 | return rc; | ||
513 | } | ||
514 | rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); | ||
515 | mutex_unlock(&server->srv_mutex); | ||
516 | |||
517 | cFYI(1, "issued NT_CANCEL for mid %u, rc = %d", | ||
518 | in_buf->Mid, rc); | ||
519 | |||
520 | return rc; | ||
521 | } | 491 | } |
522 | 492 | ||
523 | int | 493 | int |
@@ -636,7 +606,7 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, | |||
636 | 606 | ||
637 | rc = wait_for_response(ses->server, midQ); | 607 | rc = wait_for_response(ses->server, midQ); |
638 | if (rc != 0) { | 608 | if (rc != 0) { |
639 | send_nt_cancel(ses->server, (struct smb_hdr *)buf, midQ); | 609 | send_cancel(ses->server, buf, midQ); |
640 | spin_lock(&GlobalMid_Lock); | 610 | spin_lock(&GlobalMid_Lock); |
641 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { | 611 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { |
642 | midQ->callback = DeleteMidQEntry; | 612 | midQ->callback = DeleteMidQEntry; |
@@ -753,7 +723,7 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, | |||
753 | 723 | ||
754 | rc = wait_for_response(ses->server, midQ); | 724 | rc = wait_for_response(ses->server, midQ); |
755 | if (rc != 0) { | 725 | if (rc != 0) { |
756 | send_nt_cancel(ses->server, in_buf, midQ); | 726 | send_cancel(ses->server, in_buf, midQ); |
757 | spin_lock(&GlobalMid_Lock); | 727 | spin_lock(&GlobalMid_Lock); |
758 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { | 728 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { |
759 | /* no longer considered to be "in-flight" */ | 729 | /* no longer considered to be "in-flight" */ |
@@ -898,7 +868,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
898 | if (in_buf->Command == SMB_COM_TRANSACTION2) { | 868 | if (in_buf->Command == SMB_COM_TRANSACTION2) { |
899 | /* POSIX lock. We send a NT_CANCEL SMB to cause the | 869 | /* POSIX lock. We send a NT_CANCEL SMB to cause the |
900 | blocking lock to return. */ | 870 | blocking lock to return. */ |
901 | rc = send_nt_cancel(ses->server, in_buf, midQ); | 871 | rc = send_cancel(ses->server, in_buf, midQ); |
902 | if (rc) { | 872 | if (rc) { |
903 | delete_mid(midQ); | 873 | delete_mid(midQ); |
904 | return rc; | 874 | return rc; |
@@ -919,7 +889,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, | |||
919 | 889 | ||
920 | rc = wait_for_response(ses->server, midQ); | 890 | rc = wait_for_response(ses->server, midQ); |
921 | if (rc) { | 891 | if (rc) { |
922 | send_nt_cancel(ses->server, in_buf, midQ); | 892 | send_cancel(ses->server, in_buf, midQ); |
923 | spin_lock(&GlobalMid_Lock); | 893 | spin_lock(&GlobalMid_Lock); |
924 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { | 894 | if (midQ->mid_state == MID_REQUEST_SUBMITTED) { |
925 | /* no longer considered to be "in-flight" */ | 895 | /* no longer considered to be "in-flight" */ |