Commit 9789de8b authored by Zhang Xiaoxu's avatar Zhang Xiaoxu Committed by Steve French

cifs: Use help macro to get the header preamble size

It's better to use HEADER_PREAMBLE_SIZE because the unfolded expression
too long. No actual functional changes, minor readability improvement.
Signed-off-by: default avatarZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent a1d2eb51
...@@ -32,7 +32,7 @@ int __cifs_calc_signature(struct smb_rqst *rqst, ...@@ -32,7 +32,7 @@ int __cifs_calc_signature(struct smb_rqst *rqst,
int rc; int rc;
struct kvec *iov = rqst->rq_iov; struct kvec *iov = rqst->rq_iov;
int n_vec = rqst->rq_nvec; int n_vec = rqst->rq_nvec;
int is_smb2 = server->vals->header_preamble_size == 0; bool is_smb2 = HEADER_PREAMBLE_SIZE(server) == 0;
/* iov[0] is actual data and not the rfc1002 length for SMB2+ */ /* iov[0] is actual data and not the rfc1002 length for SMB2+ */
if (is_smb2) { if (is_smb2) {
......
...@@ -557,6 +557,7 @@ struct smb_version_values { ...@@ -557,6 +557,7 @@ struct smb_version_values {
#define HEADER_SIZE(server) (server->vals->header_size) #define HEADER_SIZE(server) (server->vals->header_size)
#define MAX_HEADER_SIZE(server) (server->vals->max_header_size) #define MAX_HEADER_SIZE(server) (server->vals->max_header_size)
#define HEADER_PREAMBLE_SIZE(server) (server->vals->header_preamble_size)
/** /**
* CIFS superblock mount flags (mnt_cifs_flags) to consider when * CIFS superblock mount flags (mnt_cifs_flags) to consider when
......
...@@ -871,7 +871,7 @@ smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) ...@@ -871,7 +871,7 @@ smb2_get_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
/* /*
* SMB1 does not use credits. * SMB1 does not use credits.
*/ */
if (server->vals->header_preamble_size) if (HEADER_PREAMBLE_SIZE(server))
return 0; return 0;
return le16_to_cpu(shdr->CreditRequest); return le16_to_cpu(shdr->CreditRequest);
...@@ -1050,7 +1050,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) ...@@ -1050,7 +1050,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
/* 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(server) - if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) -
server->vals->header_preamble_size) { HEADER_PREAMBLE_SIZE(server)) {
cifs_server_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length); cifs_server_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
cifs_reconnect(server, true); cifs_reconnect(server, true);
return -ECONNABORTED; return -ECONNABORTED;
...@@ -1065,8 +1065,8 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) ...@@ -1065,8 +1065,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(server) - 1, length = cifs_read_from_socket(server, buf + HEADER_SIZE(server) - 1,
pdu_length - HEADER_SIZE(server) + 1 pdu_length - HEADER_SIZE(server) + 1 +
+ server->vals->header_preamble_size); HEADER_PREAMBLE_SIZE(server));
if (length < 0) if (length < 0)
return length; return length;
...@@ -1122,7 +1122,7 @@ smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server) ...@@ -1122,7 +1122,7 @@ smb2_add_credits_from_hdr(char *buffer, struct TCP_Server_Info *server)
/* /*
* SMB1 does not use credits. * SMB1 does not use credits.
*/ */
if (server->vals->header_preamble_size) if (HEADER_PREAMBLE_SIZE(server))
return; return;
if (shdr->CreditRequest) { if (shdr->CreditRequest) {
...@@ -1180,7 +1180,7 @@ cifs_demultiplex_thread(void *p) ...@@ -1180,7 +1180,7 @@ cifs_demultiplex_thread(void *p)
if (length < 0) if (length < 0)
continue; continue;
if (server->vals->header_preamble_size == 0) if (HEADER_PREAMBLE_SIZE(server) == 0)
server->total_read = 0; server->total_read = 0;
else else
server->total_read = length; server->total_read = length;
...@@ -1199,7 +1199,7 @@ cifs_demultiplex_thread(void *p) ...@@ -1199,7 +1199,7 @@ cifs_demultiplex_thread(void *p)
/* make sure we have enough to get to the MID */ /* make sure we have enough to get to the MID */
if (server->pdu_size < HEADER_SIZE(server) - 1 - if (server->pdu_size < HEADER_SIZE(server) - 1 -
server->vals->header_preamble_size) { HEADER_PREAMBLE_SIZE(server)) {
cifs_server_dbg(VFS, "SMB response too short (%u bytes)\n", cifs_server_dbg(VFS, "SMB response too short (%u bytes)\n",
server->pdu_size); server->pdu_size);
cifs_reconnect(server, true); cifs_reconnect(server, true);
...@@ -1208,9 +1208,9 @@ cifs_demultiplex_thread(void *p) ...@@ -1208,9 +1208,9 @@ cifs_demultiplex_thread(void *p)
/* read down to the MID */ /* read down to the MID */
length = cifs_read_from_socket(server, length = cifs_read_from_socket(server,
buf + server->vals->header_preamble_size, buf + HEADER_PREAMBLE_SIZE(server),
HEADER_SIZE(server) - 1 HEADER_SIZE(server) - 1 -
- server->vals->header_preamble_size); HEADER_PREAMBLE_SIZE(server));
if (length < 0) if (length < 0)
continue; continue;
server->total_read += length; server->total_read += length;
......
...@@ -261,8 +261,8 @@ smb_rqst_len(struct TCP_Server_Info *server, struct smb_rqst *rqst) ...@@ -261,8 +261,8 @@ smb_rqst_len(struct TCP_Server_Info *server, struct smb_rqst *rqst)
int nvec; int nvec;
unsigned long buflen = 0; unsigned long buflen = 0;
if (server->vals->header_preamble_size == 0 && if (HEADER_PREAMBLE_SIZE(server) == 0 && rqst->rq_nvec >= 2 &&
rqst->rq_nvec >= 2 && rqst->rq_iov[0].iov_len == 4) { rqst->rq_iov[0].iov_len == 4) {
iov = &rqst->rq_iov[1]; iov = &rqst->rq_iov[1];
nvec = rqst->rq_nvec - 1; nvec = rqst->rq_nvec - 1;
} else { } else {
...@@ -346,7 +346,7 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, ...@@ -346,7 +346,7 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
sigprocmask(SIG_BLOCK, &mask, &oldmask); sigprocmask(SIG_BLOCK, &mask, &oldmask);
/* Generate a rfc1002 marker for SMB2+ */ /* Generate a rfc1002 marker for SMB2+ */
if (server->vals->header_preamble_size == 0) { if (HEADER_PREAMBLE_SIZE(server) == 0) {
struct kvec hiov = { struct kvec hiov = {
.iov_base = &rfc1002_marker, .iov_base = &rfc1002_marker,
.iov_len = 4 .iov_len = 4
...@@ -1238,7 +1238,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -1238,7 +1238,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
buf = (char *)midQ[i]->resp_buf; buf = (char *)midQ[i]->resp_buf;
resp_iov[i].iov_base = buf; resp_iov[i].iov_base = buf;
resp_iov[i].iov_len = midQ[i]->resp_buf_size + resp_iov[i].iov_len = midQ[i]->resp_buf_size +
server->vals->header_preamble_size; HEADER_PREAMBLE_SIZE(server);
if (midQ[i]->large_buf) if (midQ[i]->large_buf)
resp_buf_type[i] = CIFS_LARGE_BUFFER; resp_buf_type[i] = CIFS_LARGE_BUFFER;
...@@ -1643,7 +1643,7 @@ int ...@@ -1643,7 +1643,7 @@ int
cifs_discard_remaining_data(struct TCP_Server_Info *server) cifs_discard_remaining_data(struct TCP_Server_Info *server)
{ {
unsigned int rfclen = server->pdu_size; unsigned int rfclen = server->pdu_size;
int remaining = rfclen + server->vals->header_preamble_size - int remaining = rfclen + HEADER_PREAMBLE_SIZE(server) -
server->total_read; server->total_read;
while (remaining > 0) { while (remaining > 0) {
...@@ -1689,8 +1689,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) ...@@ -1689,8 +1689,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
unsigned int data_offset, data_len; unsigned int data_offset, data_len;
struct cifs_readdata *rdata = mid->callback_data; struct cifs_readdata *rdata = mid->callback_data;
char *buf = server->smallbuf; char *buf = server->smallbuf;
unsigned int buflen = server->pdu_size + unsigned int buflen = server->pdu_size + HEADER_PREAMBLE_SIZE(server);
server->vals->header_preamble_size;
bool use_rdma_mr = false; bool use_rdma_mr = false;
cifs_dbg(FYI, "%s: mid=%llu offset=%llu bytes=%u\n", cifs_dbg(FYI, "%s: mid=%llu offset=%llu bytes=%u\n",
...@@ -1724,10 +1723,10 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) ...@@ -1724,10 +1723,10 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
/* set up first two iov for signature check and to get credits */ /* set up first two iov for signature check and to get credits */
rdata->iov[0].iov_base = buf; rdata->iov[0].iov_base = buf;
rdata->iov[0].iov_len = server->vals->header_preamble_size; rdata->iov[0].iov_len = HEADER_PREAMBLE_SIZE(server);
rdata->iov[1].iov_base = buf + server->vals->header_preamble_size; rdata->iov[1].iov_base = buf + HEADER_PREAMBLE_SIZE(server);
rdata->iov[1].iov_len = rdata->iov[1].iov_len =
server->total_read - server->vals->header_preamble_size; server->total_read - HEADER_PREAMBLE_SIZE(server);
cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n", cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n",
rdata->iov[0].iov_base, rdata->iov[0].iov_len); rdata->iov[0].iov_base, rdata->iov[0].iov_len);
cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n", cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n",
...@@ -1752,7 +1751,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) ...@@ -1752,7 +1751,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
} }
data_offset = server->ops->read_data_offset(buf) + data_offset = server->ops->read_data_offset(buf) +
server->vals->header_preamble_size; HEADER_PREAMBLE_SIZE(server);
if (data_offset < server->total_read) { if (data_offset < server->total_read) {
/* /*
* win2k8 sometimes sends an offset of 0 when the read * win2k8 sometimes sends an offset of 0 when the read
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment