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>
This commit is contained in:
parent
082d0642c6
commit
1887f60103
4 changed files with 20 additions and 23 deletions
|
@ -177,8 +177,13 @@ struct smb_version_values {
|
||||||
__u32 exclusive_lock_type;
|
__u32 exclusive_lock_type;
|
||||||
__u32 shared_lock_type;
|
__u32 shared_lock_type;
|
||||||
__u32 unlock_lock_type;
|
__u32 unlock_lock_type;
|
||||||
|
size_t header_size;
|
||||||
|
size_t max_header_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define HEADER_SIZE(server) (server->vals->header_size)
|
||||||
|
#define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
|
||||||
|
|
||||||
struct smb_vol {
|
struct smb_vol {
|
||||||
char *username;
|
char *username;
|
||||||
char *password;
|
char *password;
|
||||||
|
@ -374,18 +379,6 @@ has_credits(struct TCP_Server_Info *server, int *credits)
|
||||||
return num > 0;
|
return num > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline size_t
|
|
||||||
header_size(void)
|
|
||||||
{
|
|
||||||
return sizeof(struct smb_hdr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline size_t
|
|
||||||
max_header_size(void)
|
|
||||||
{
|
|
||||||
return MAX_CIFS_HDR_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Macros to allow the TCP_Server_Info->net field and related code to drop out
|
* Macros to allow the TCP_Server_Info->net field and related code to drop out
|
||||||
* when CONFIG_NET_NS isn't set.
|
* when CONFIG_NET_NS isn't set.
|
||||||
|
|
|
@ -1400,7 +1400,7 @@ cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
||||||
|
|
||||||
length = cifs_read_from_socket(server, server->bigbuf,
|
length = cifs_read_from_socket(server, server->bigbuf,
|
||||||
min_t(unsigned int, remaining,
|
min_t(unsigned int, remaining,
|
||||||
CIFSMaxBufSize + max_header_size()));
|
CIFSMaxBufSize + MAX_HEADER_SIZE(server)));
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
return length;
|
return length;
|
||||||
server->total_read += length;
|
server->total_read += length;
|
||||||
|
@ -1449,9 +1449,10 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
||||||
* can if there's not enough data. At this point, we've read down to
|
* can if there's not enough data. At this point, we've read down to
|
||||||
* the Mid.
|
* the Mid.
|
||||||
*/
|
*/
|
||||||
len = min_t(unsigned int, buflen, read_rsp_size()) - header_size() + 1;
|
len = min_t(unsigned int, buflen, read_rsp_size()) -
|
||||||
|
HEADER_SIZE(server) + 1;
|
||||||
|
|
||||||
rdata->iov[0].iov_base = buf + header_size() - 1;
|
rdata->iov[0].iov_base = buf + HEADER_SIZE(server) - 1;
|
||||||
rdata->iov[0].iov_len = len;
|
rdata->iov[0].iov_len = len;
|
||||||
|
|
||||||
length = cifs_readv_from_socket(server, rdata->iov, 1, len);
|
length = cifs_readv_from_socket(server, rdata->iov, 1, len);
|
||||||
|
|
|
@ -568,7 +568,7 @@ allocate_buffers(struct TCP_Server_Info *server)
|
||||||
}
|
}
|
||||||
} else if (server->large_buf) {
|
} else if (server->large_buf) {
|
||||||
/* we are reusing a dirty large buf, clear its start */
|
/* we are reusing a dirty large buf, clear its start */
|
||||||
memset(server->bigbuf, 0, header_size());
|
memset(server->bigbuf, 0, HEADER_SIZE(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!server->smallbuf) {
|
if (!server->smallbuf) {
|
||||||
|
@ -582,7 +582,7 @@ allocate_buffers(struct TCP_Server_Info *server)
|
||||||
/* beginning of smb buffer is cleared in our buf_get */
|
/* beginning of smb buffer is cleared in our buf_get */
|
||||||
} else {
|
} else {
|
||||||
/* if existing small buf clear beginning */
|
/* if existing small buf clear beginning */
|
||||||
memset(server->smallbuf, 0, header_size());
|
memset(server->smallbuf, 0, HEADER_SIZE(server));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -953,7 +953,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
||||||
unsigned int pdu_length = get_rfc1002_length(buf);
|
unsigned int pdu_length = get_rfc1002_length(buf);
|
||||||
|
|
||||||
/* make sure this will fit in a large buffer */
|
/* make sure this will fit in a large buffer */
|
||||||
if (pdu_length > CIFSMaxBufSize + max_header_size() - 4) {
|
if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) - 4) {
|
||||||
cERROR(1, "SMB response too long (%u bytes)",
|
cERROR(1, "SMB response too long (%u bytes)",
|
||||||
pdu_length);
|
pdu_length);
|
||||||
cifs_reconnect(server);
|
cifs_reconnect(server);
|
||||||
|
@ -969,8 +969,8 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now read the rest */
|
/* now read the rest */
|
||||||
length = cifs_read_from_socket(server, buf + header_size() - 1,
|
length = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1,
|
||||||
pdu_length - header_size() + 1 + 4);
|
pdu_length - HEADER_SIZE(server) + 1 + 4);
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
return length;
|
return length;
|
||||||
server->total_read += length;
|
server->total_read += length;
|
||||||
|
@ -1044,7 +1044,7 @@ cifs_demultiplex_thread(void *p)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* make sure we have enough to get to the MID */
|
/* make sure we have enough to get to the MID */
|
||||||
if (pdu_length < header_size() - 1 - 4) {
|
if (pdu_length < HEADER_SIZE(server) - 1 - 4) {
|
||||||
cERROR(1, "SMB response too short (%u bytes)",
|
cERROR(1, "SMB response too short (%u bytes)",
|
||||||
pdu_length);
|
pdu_length);
|
||||||
cifs_reconnect(server);
|
cifs_reconnect(server);
|
||||||
|
@ -1054,7 +1054,7 @@ cifs_demultiplex_thread(void *p)
|
||||||
|
|
||||||
/* read down to the MID */
|
/* read down to the MID */
|
||||||
length = cifs_read_from_socket(server, buf + 4,
|
length = cifs_read_from_socket(server, buf + 4,
|
||||||
header_size() - 1 - 4);
|
HEADER_SIZE(server) - 1 - 4);
|
||||||
if (length < 0)
|
if (length < 0)
|
||||||
continue;
|
continue;
|
||||||
server->total_read += length;
|
server->total_read += length;
|
||||||
|
@ -1079,7 +1079,8 @@ cifs_demultiplex_thread(void *p)
|
||||||
} else if (!is_valid_oplock_break(buf, server)) {
|
} else if (!is_valid_oplock_break(buf, server)) {
|
||||||
cERROR(1, "No task to wake, unknown frame received! "
|
cERROR(1, "No task to wake, unknown frame received! "
|
||||||
"NumMids %d", atomic_read(&midCount));
|
"NumMids %d", atomic_read(&midCount));
|
||||||
cifs_dump_mem("Received Data is: ", buf, header_size());
|
cifs_dump_mem("Received Data is: ", buf,
|
||||||
|
HEADER_SIZE(server));
|
||||||
#ifdef CONFIG_CIFS_DEBUG2
|
#ifdef CONFIG_CIFS_DEBUG2
|
||||||
cifs_dump_detail(buf);
|
cifs_dump_detail(buf);
|
||||||
cifs_dump_mids(server);
|
cifs_dump_mids(server);
|
||||||
|
|
|
@ -79,4 +79,6 @@ struct smb_version_values smb1_values = {
|
||||||
.exclusive_lock_type = 0,
|
.exclusive_lock_type = 0,
|
||||||
.shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
|
.shared_lock_type = LOCKING_ANDX_SHARED_LOCK,
|
||||||
.unlock_lock_type = 0,
|
.unlock_lock_type = 0,
|
||||||
|
.header_size = sizeof(struct smb_hdr),
|
||||||
|
.max_header_size = MAX_CIFS_HDR_SIZE,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue