diff options
author | Pavel Shilovsky <piastry@etersoft.ru> | 2012-05-17 04:45:31 -0400 |
---|---|---|
committer | Pavel Shilovsky <pshilovsky@samba.org> | 2012-05-23 04:33:08 -0400 |
commit | 1887f60103aaeeeb7a3fbf3b366d626043873164 (patch) | |
tree | fda4c3574550dd4d84f7c656748671edeec7468b /fs/cifs | |
parent | 082d0642c61fc309ca7f6133968ba1264193dcc1 (diff) |
CIFS: Move header_size/max_header_size to ops structure
Acked-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Reviewed-by: Jeff Layton <jlayton@redhat.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/cifsglob.h | 17 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 7 | ||||
-rw-r--r-- | fs/cifs/connect.c | 17 | ||||
-rw-r--r-- | fs/cifs/smb1ops.c | 2 |
4 files changed, 20 insertions, 23 deletions
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 5b108382902a..9ee832d29ec7 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h | |||
@@ -177,8 +177,13 @@ struct smb_version_values { | |||
177 | __u32 exclusive_lock_type; | 177 | __u32 exclusive_lock_type; |
178 | __u32 shared_lock_type; | 178 | __u32 shared_lock_type; |
179 | __u32 unlock_lock_type; | 179 | __u32 unlock_lock_type; |
180 | size_t header_size; | ||
181 | size_t max_header_size; | ||
180 | }; | 182 | }; |
181 | 183 | ||
184 | #define HEADER_SIZE(server) (server->vals->header_size) | ||
185 | #define MAX_HEADER_SIZE(server) (server->vals->max_header_size) | ||
186 | |||
182 | struct smb_vol { | 187 | struct smb_vol { |
183 | char *username; | 188 | char *username; |
184 | char *password; | 189 | char *password; |
@@ -374,18 +379,6 @@ has_credits(struct TCP_Server_Info *server, int *credits) | |||
374 | return num > 0; | 379 | return num > 0; |
375 | } | 380 | } |
376 | 381 | ||
377 | static inline size_t | ||
378 | header_size(void) | ||
379 | { | ||
380 | return sizeof(struct smb_hdr); | ||
381 | } | ||
382 | |||
383 | static inline size_t | ||
384 | max_header_size(void) | ||
385 | { | ||
386 | return MAX_CIFS_HDR_SIZE; | ||
387 | } | ||
388 | |||
389 | /* | 382 | /* |
390 | * Macros to allow the TCP_Server_Info->net field and related code to drop out | 383 | * Macros to allow the TCP_Server_Info->net field and related code to drop out |
391 | * when CONFIG_NET_NS isn't set. | 384 | * when CONFIG_NET_NS isn't set. |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 3563c93d9f17..77463f701f01 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -1400,7 +1400,7 @@ cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
1400 | 1400 | ||
1401 | length = cifs_read_from_socket(server, server->bigbuf, | 1401 | length = cifs_read_from_socket(server, server->bigbuf, |
1402 | min_t(unsigned int, remaining, | 1402 | min_t(unsigned int, remaining, |
1403 | CIFSMaxBufSize + max_header_size())); | 1403 | CIFSMaxBufSize + MAX_HEADER_SIZE(server))); |
1404 | if (length < 0) | 1404 | if (length < 0) |
1405 | return length; | 1405 | return length; |
1406 | server->total_read += length; | 1406 | server->total_read += length; |
@@ -1449,9 +1449,10 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
1449 | * can if there's not enough data. At this point, we've read down to | 1449 | * can if there's not enough data. At this point, we've read down to |
1450 | * the Mid. | 1450 | * the Mid. |
1451 | */ | 1451 | */ |
1452 | len = min_t(unsigned int, buflen, read_rsp_size()) - header_size() + 1; | 1452 | len = min_t(unsigned int, buflen, read_rsp_size()) - |
1453 | HEADER_SIZE(server) + 1; | ||
1453 | 1454 | ||
1454 | rdata->iov[0].iov_base = buf + header_size() - 1; | 1455 | rdata->iov[0].iov_base = buf + HEADER_SIZE(server) - 1; |
1455 | rdata->iov[0].iov_len = len; | 1456 | rdata->iov[0].iov_len = len; |
1456 | 1457 | ||
1457 | length = cifs_readv_from_socket(server, rdata->iov, 1, len); | 1458 | length = cifs_readv_from_socket(server, rdata->iov, 1, len); |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 5ac20fc2c312..65ec6ef0995e 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -568,7 +568,7 @@ allocate_buffers(struct TCP_Server_Info *server) | |||
568 | } | 568 | } |
569 | } else if (server->large_buf) { | 569 | } else if (server->large_buf) { |
570 | /* we are reusing a dirty large buf, clear its start */ | 570 | /* we are reusing a dirty large buf, clear its start */ |
571 | memset(server->bigbuf, 0, header_size()); | 571 | memset(server->bigbuf, 0, HEADER_SIZE(server)); |
572 | } | 572 | } |
573 | 573 | ||
574 | if (!server->smallbuf) { | 574 | if (!server->smallbuf) { |
@@ -582,7 +582,7 @@ allocate_buffers(struct TCP_Server_Info *server) | |||
582 | /* beginning of smb buffer is cleared in our buf_get */ | 582 | /* beginning of smb buffer is cleared in our buf_get */ |
583 | } else { | 583 | } else { |
584 | /* if existing small buf clear beginning */ | 584 | /* if existing small buf clear beginning */ |
585 | memset(server->smallbuf, 0, header_size()); | 585 | memset(server->smallbuf, 0, HEADER_SIZE(server)); |
586 | } | 586 | } |
587 | 587 | ||
588 | return true; | 588 | return true; |
@@ -953,7 +953,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
953 | unsigned int pdu_length = get_rfc1002_length(buf); | 953 | unsigned int pdu_length = get_rfc1002_length(buf); |
954 | 954 | ||
955 | /* make sure this will fit in a large buffer */ | 955 | /* make sure this will fit in a large buffer */ |
956 | if (pdu_length > CIFSMaxBufSize + max_header_size() - 4) { | 956 | if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) - 4) { |
957 | cERROR(1, "SMB response too long (%u bytes)", | 957 | cERROR(1, "SMB response too long (%u bytes)", |
958 | pdu_length); | 958 | pdu_length); |
959 | cifs_reconnect(server); | 959 | cifs_reconnect(server); |
@@ -969,8 +969,8 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) | |||
969 | } | 969 | } |
970 | 970 | ||
971 | /* now read the rest */ | 971 | /* now read the rest */ |
972 | length = cifs_read_from_socket(server, buf + header_size() - 1, | 972 | length = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1, |
973 | pdu_length - header_size() + 1 + 4); | 973 | pdu_length - HEADER_SIZE(server) + 1 + 4); |
974 | if (length < 0) | 974 | if (length < 0) |
975 | return length; | 975 | return length; |
976 | server->total_read += length; | 976 | server->total_read += length; |
@@ -1044,7 +1044,7 @@ cifs_demultiplex_thread(void *p) | |||
1044 | continue; | 1044 | continue; |
1045 | 1045 | ||
1046 | /* make sure we have enough to get to the MID */ | 1046 | /* make sure we have enough to get to the MID */ |
1047 | if (pdu_length < header_size() - 1 - 4) { | 1047 | if (pdu_length < HEADER_SIZE(server) - 1 - 4) { |
1048 | cERROR(1, "SMB response too short (%u bytes)", | 1048 | cERROR(1, "SMB response too short (%u bytes)", |
1049 | pdu_length); | 1049 | pdu_length); |
1050 | cifs_reconnect(server); | 1050 | cifs_reconnect(server); |
@@ -1054,7 +1054,7 @@ cifs_demultiplex_thread(void *p) | |||
1054 | 1054 | ||
1055 | /* read down to the MID */ | 1055 | /* read down to the MID */ |
1056 | length = cifs_read_from_socket(server, buf + 4, | 1056 | length = cifs_read_from_socket(server, buf + 4, |
1057 | header_size() - 1 - 4); | 1057 | HEADER_SIZE(server) - 1 - 4); |
1058 | if (length < 0) | 1058 | if (length < 0) |
1059 | continue; | 1059 | continue; |
1060 | server->total_read += length; | 1060 | server->total_read += length; |
@@ -1079,7 +1079,8 @@ cifs_demultiplex_thread(void *p) | |||
1079 | } else if (!is_valid_oplock_break(buf, server)) { | 1079 | } else if (!is_valid_oplock_break(buf, server)) { |
1080 | cERROR(1, "No task to wake, unknown frame received! " | 1080 | cERROR(1, "No task to wake, unknown frame received! " |
1081 | "NumMids %d", atomic_read(&midCount)); | 1081 | "NumMids %d", atomic_read(&midCount)); |
1082 | cifs_dump_mem("Received Data is: ", buf, header_size()); | 1082 | cifs_dump_mem("Received Data is: ", buf, |
1083 | HEADER_SIZE(server)); | ||
1083 | #ifdef CONFIG_CIFS_DEBUG2 | 1084 | #ifdef CONFIG_CIFS_DEBUG2 |
1084 | cifs_dump_detail(buf); | 1085 | cifs_dump_detail(buf); |
1085 | cifs_dump_mids(server); | 1086 | cifs_dump_mids(server); |
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c index 9cf76e89745f..3668e81a9d81 100644 --- a/fs/cifs/smb1ops.c +++ b/fs/cifs/smb1ops.c | |||
@@ -79,4 +79,6 @@ struct smb_version_values smb1_values = { | |||
79 | .exclusive_lock_type = 0, | 79 | .exclusive_lock_type = 0, |
80 | .shared_lock_type = LOCKING_ANDX_SHARED_LOCK, | 80 | .shared_lock_type = LOCKING_ANDX_SHARED_LOCK, |
81 | .unlock_lock_type = 0, | 81 | .unlock_lock_type = 0, |
82 | .header_size = sizeof(struct smb_hdr), | ||
83 | .max_header_size = MAX_CIFS_HDR_SIZE, | ||
82 | }; | 84 | }; |