diff options
author | Pavel Shilovsky <piastry@etersoft.ru> | 2012-05-17 05:25:35 -0400 |
---|---|---|
committer | Pavel Shilovsky <pshilovsky@samba.org> | 2012-05-23 04:33:11 -0400 |
commit | 8aa26f3ed80ddbaf78804b6481fcfdbd447caa1c (patch) | |
tree | 7c0a61eb9711dd93bb5eda33d875fbdd7c20a0e4 /fs/cifs | |
parent | eb37871118abfc30629ee2bef11013eddb42c756 (diff) |
CIFS: Move protocol specific demultiplex thread calls to ops struct
Acked-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifs_debug.c | 6 | ||||
-rw-r--r-- | fs/cifs/cifs_debug.h | 4 | ||||
-rw-r--r-- | fs/cifs/cifsglob.h | 6 | ||||
-rw-r--r-- | fs/cifs/connect.c | 27 | ||||
-rw-r--r-- | fs/cifs/smb1ops.c | 23 |
5 files changed, 39 insertions, 27 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 8aae8e28038c..e8140528ca5c 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -57,19 +57,21 @@ cifs_dump_mem(char *label, void *data, int length) | |||
57 | } | 57 | } |
58 | } | 58 | } |
59 | 59 | ||
60 | #ifdef CONFIG_CIFS_DEBUG2 | ||
61 | void cifs_dump_detail(void *buf) | 60 | void cifs_dump_detail(void *buf) |
62 | { | 61 | { |
62 | #ifdef CONFIG_CIFS_DEBUG2 | ||
63 | struct smb_hdr *smb = (struct smb_hdr *)buf; | 63 | struct smb_hdr *smb = (struct smb_hdr *)buf; |
64 | 64 | ||
65 | cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", | 65 | cERROR(1, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d", |
66 | smb->Command, smb->Status.CifsError, | 66 | smb->Command, smb->Status.CifsError, |
67 | smb->Flags, smb->Flags2, smb->Mid, smb->Pid); | 67 | smb->Flags, smb->Flags2, smb->Mid, smb->Pid); |
68 | cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb)); | 68 | cERROR(1, "smb buf %p len %d", smb, smbCalcSize(smb)); |
69 | #endif /* CONFIG_CIFS_DEBUG2 */ | ||
69 | } | 70 | } |
70 | 71 | ||
71 | void cifs_dump_mids(struct TCP_Server_Info *server) | 72 | void cifs_dump_mids(struct TCP_Server_Info *server) |
72 | { | 73 | { |
74 | #ifdef CONFIG_CIFS_DEBUG2 | ||
73 | struct list_head *tmp; | 75 | struct list_head *tmp; |
74 | struct mid_q_entry *mid_entry; | 76 | struct mid_q_entry *mid_entry; |
75 | 77 | ||
@@ -102,8 +104,8 @@ void cifs_dump_mids(struct TCP_Server_Info *server) | |||
102 | } | 104 | } |
103 | } | 105 | } |
104 | spin_unlock(&GlobalMid_Lock); | 106 | spin_unlock(&GlobalMid_Lock); |
105 | } | ||
106 | #endif /* CONFIG_CIFS_DEBUG2 */ | 107 | #endif /* CONFIG_CIFS_DEBUG2 */ |
108 | } | ||
107 | 109 | ||
108 | #ifdef CONFIG_PROC_FS | 110 | #ifdef CONFIG_PROC_FS |
109 | static int cifs_debug_data_proc_show(struct seq_file *m, void *v) | 111 | static int cifs_debug_data_proc_show(struct seq_file *m, void *v) |
diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h index 566e0ae8dc2c..c0c68bb492d7 100644 --- a/fs/cifs/cifs_debug.h +++ b/fs/cifs/cifs_debug.h | |||
@@ -24,10 +24,10 @@ | |||
24 | #define _H_CIFS_DEBUG | 24 | #define _H_CIFS_DEBUG |
25 | 25 | ||
26 | void cifs_dump_mem(char *label, void *data, int length); | 26 | void cifs_dump_mem(char *label, void *data, int length); |
27 | #ifdef CONFIG_CIFS_DEBUG2 | ||
28 | #define DBG2 2 | ||
29 | void cifs_dump_detail(void *); | 27 | void cifs_dump_detail(void *); |
30 | void cifs_dump_mids(struct TCP_Server_Info *); | 28 | void cifs_dump_mids(struct TCP_Server_Info *); |
29 | #ifdef CONFIG_CIFS_DEBUG2 | ||
30 | #define DBG2 2 | ||
31 | #else | 31 | #else |
32 | #define DBG2 0 | 32 | #define DBG2 0 |
33 | #endif | 33 | #endif |
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 825140170b1e..1001924f594a 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -175,6 +175,12 @@ struct smb_version_operations { | |||
175 | unsigned int (*read_data_length)(char *); | 175 | unsigned int (*read_data_length)(char *); |
176 | /* map smb to linux error */ | 176 | /* map smb to linux error */ |
177 | int (*map_error)(char *, bool); | 177 | int (*map_error)(char *, bool); |
178 | /* find mid corresponding to the response message */ | ||
179 | struct mid_q_entry * (*find_mid)(struct TCP_Server_Info *, char *); | ||
180 | void (*dump_detail)(void *); | ||
181 | /* verify the message */ | ||
182 | int (*check_message)(char *, unsigned int); | ||
183 | bool (*is_oplock_break)(char *, struct TCP_Server_Info *); | ||
178 | }; | 184 | }; |
179 | 185 | ||
180 | struct smb_version_values { | 186 | struct smb_version_values { |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 65ec6ef0995e..ce033d74f315 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -783,25 +783,6 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type) | |||
783 | return false; | 783 | return false; |
784 | } | 784 | } |
785 | 785 | ||
786 | static struct mid_q_entry * | ||
787 | find_mid(struct TCP_Server_Info *server, char *buffer) | ||
788 | { | ||
789 | struct smb_hdr *buf = (struct smb_hdr *)buffer; | ||
790 | struct mid_q_entry *mid; | ||
791 | |||
792 | spin_lock(&GlobalMid_Lock); | ||
793 | list_for_each_entry(mid, &server->pending_mid_q, qhead) { | ||
794 | if (mid->mid == buf->Mid && | ||
795 | mid->mid_state == MID_REQUEST_SUBMITTED && | ||
796 | le16_to_cpu(mid->command) == buf->Command) { | ||
797 | spin_unlock(&GlobalMid_Lock); | ||
798 | return mid; | ||
799 | } | ||
800 | } | ||
801 | spin_unlock(&GlobalMid_Lock); | ||
802 | return NULL; | ||
803 | } | ||
804 | |||
805 | void | 786 | void |
806 | dequeue_mid(struct mid_q_entry *mid, bool malformed) | 787 | dequeue_mid(struct mid_q_entry *mid, bool malformed) |
807 | { | 788 | { |
@@ -986,7 +967,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
986 | * 48 bytes is enough to display the header and a little bit | 967 | * 48 bytes is enough to display the header and a little bit |
987 | * into the payload for debugging purposes. | 968 | * into the payload for debugging purposes. |
988 | */ | 969 | */ |
989 | length = checkSMB(buf, server->total_read); | 970 | length = server->ops->check_message(buf, server->total_read); |
990 | if (length != 0) | 971 | if (length != 0) |
991 | cifs_dump_mem("Bad SMB: ", buf, | 972 | cifs_dump_mem("Bad SMB: ", buf, |
992 | min_t(unsigned int, server->total_read, 48)); | 973 | min_t(unsigned int, server->total_read, 48)); |
@@ -1059,7 +1040,7 @@ cifs_demultiplex_thread(void *p) | |||
1059 | continue; | 1040 | continue; |
1060 | server->total_read += length; | 1041 | server->total_read += length; |
1061 | 1042 | ||
1062 | mid_entry = find_mid(server, buf); | 1043 | mid_entry = server->ops->find_mid(server, buf); |
1063 | 1044 | ||
1064 | if (!mid_entry || !mid_entry->receive) | 1045 | if (!mid_entry || !mid_entry->receive) |
1065 | length = standard_receive3(server, mid_entry); | 1046 | length = standard_receive3(server, mid_entry); |
@@ -1076,13 +1057,13 @@ cifs_demultiplex_thread(void *p) | |||
1076 | if (mid_entry != NULL) { | 1057 | if (mid_entry != NULL) { |
1077 | if (!mid_entry->multiRsp || mid_entry->multiEnd) | 1058 | if (!mid_entry->multiRsp || mid_entry->multiEnd) |
1078 | mid_entry->callback(mid_entry); | 1059 | mid_entry->callback(mid_entry); |
1079 | } else if (!is_valid_oplock_break(buf, server)) { | 1060 | } else if (!server->ops->is_oplock_break(buf, server)) { |
1080 | cERROR(1, "No task to wake, unknown frame received! " | 1061 | cERROR(1, "No task to wake, unknown frame received! " |
1081 | "NumMids %d", atomic_read(&midCount)); | 1062 | "NumMids %d", atomic_read(&midCount)); |
1082 | cifs_dump_mem("Received Data is: ", buf, | 1063 | cifs_dump_mem("Received Data is: ", buf, |
1083 | HEADER_SIZE(server)); | 1064 | HEADER_SIZE(server)); |
1084 | #ifdef CONFIG_CIFS_DEBUG2 | 1065 | #ifdef CONFIG_CIFS_DEBUG2 |
1085 | cifs_dump_detail(buf); | 1066 | server->ops->dump_detail(buf); |
1086 | cifs_dump_mids(server); | 1067 | cifs_dump_mids(server); |
1087 | #endif /* CIFS_DEBUG2 */ | 1068 | #endif /* CIFS_DEBUG2 */ |
1088 | 1069 | ||
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index daa2edec391e..ddc8ca6c3090 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c | |||
@@ -81,6 +81,25 @@ cifs_read_data_length(char *buf) | |||
81 | le16_to_cpu(rsp->DataLength); | 81 | le16_to_cpu(rsp->DataLength); |
82 | } | 82 | } |
83 | 83 | ||
84 | static struct mid_q_entry * | ||
85 | cifs_find_mid(struct TCP_Server_Info *server, char *buffer) | ||
86 | { | ||
87 | struct smb_hdr *buf = (struct smb_hdr *)buffer; | ||
88 | struct mid_q_entry *mid; | ||
89 | |||
90 | spin_lock(&GlobalMid_Lock); | ||
91 | list_for_each_entry(mid, &server->pending_mid_q, qhead) { | ||
92 | if (mid->mid == buf->Mid && | ||
93 | mid->mid_state == MID_REQUEST_SUBMITTED && | ||
94 | le16_to_cpu(mid->command) == buf->Command) { | ||
95 | spin_unlock(&GlobalMid_Lock); | ||
96 | return mid; | ||
97 | } | ||
98 | } | ||
99 | spin_unlock(&GlobalMid_Lock); | ||
100 | return NULL; | ||
101 | } | ||
102 | |||
84 | struct smb_version_operations smb1_operations = { | 103 | struct smb_version_operations smb1_operations = { |
85 | .send_cancel = send_nt_cancel, | 104 | .send_cancel = send_nt_cancel, |
86 | .compare_fids = cifs_compare_fids, | 105 | .compare_fids = cifs_compare_fids, |
@@ -89,6 +108,10 @@ struct smb_version_operations smb1_operations = { | |||
89 | .read_data_offset = cifs_read_data_offset, | 108 | .read_data_offset = cifs_read_data_offset, |
90 | .read_data_length = cifs_read_data_length, | 109 | .read_data_length = cifs_read_data_length, |
91 | .map_error = map_smb_to_linux_error, | 110 | .map_error = map_smb_to_linux_error, |
111 | .find_mid = cifs_find_mid, | ||
112 | .check_message = checkSMB, | ||
113 | .dump_detail = cifs_dump_detail, | ||
114 | .is_oplock_break = is_valid_oplock_break, | ||
92 | }; | 115 | }; |
93 | 116 | ||
94 | struct smb_version_values smb1_values = { | 117 | struct smb_version_values smb1_values = { |