Commit 07cd952f authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French

cifs: update __smb_send_rqst() to take an array of requests

Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 40eff45b
...@@ -202,7 +202,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg, ...@@ -202,7 +202,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
} }
static unsigned long static unsigned long
rqst_len(struct smb_rqst *rqst) smb2_rqst_len(struct smb_rqst *rqst)
{ {
unsigned int i; unsigned int i;
struct kvec *iov = rqst->rq_iov; struct kvec *iov = rqst->rq_iov;
...@@ -236,13 +236,14 @@ rqst_len(struct smb_rqst *rqst) ...@@ -236,13 +236,14 @@ rqst_len(struct smb_rqst *rqst)
} }
static int static int
__smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst) __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
struct smb_rqst *rqst)
{ {
int rc; int rc = 0;
struct kvec *iov = rqst->rq_iov; struct kvec *iov;
int n_vec = rqst->rq_nvec; int n_vec;
unsigned int send_length; unsigned int send_length = 0;
unsigned int i; unsigned int i, j;
size_t total_len = 0, sent, size; size_t total_len = 0, sent, size;
struct socket *ssocket = server->ssocket; struct socket *ssocket = server->ssocket;
struct msghdr smb_msg; struct msghdr smb_msg;
...@@ -256,14 +257,14 @@ __smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst) ...@@ -256,14 +257,14 @@ __smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst)
if (ssocket == NULL) if (ssocket == NULL)
return -ENOTSOCK; return -ENOTSOCK;
send_length = rqst_len(rqst);
rfc1002_marker = cpu_to_be32(send_length);
/* cork the socket */ /* cork the socket */
kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK, kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,
(char *)&val, sizeof(val)); (char *)&val, sizeof(val));
size = 0; for (j = 0; j < num_rqst; j++)
send_length += smb2_rqst_len(&rqst[j]);
rfc1002_marker = cpu_to_be32(send_length);
/* Generate a rfc1002 marker for SMB2+ */ /* Generate a rfc1002 marker for SMB2+ */
if (server->vals->header_preamble_size == 0) { if (server->vals->header_preamble_size == 0) {
struct kvec hiov = { struct kvec hiov = {
...@@ -280,35 +281,43 @@ __smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst) ...@@ -280,35 +281,43 @@ __smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst)
send_length += 4; send_length += 4;
} }
cifs_dbg(FYI, "Sending smb: smb_len=%u\n", send_length); for (j = 0; j < num_rqst; j++) {
dump_smb(iov[0].iov_base, iov[0].iov_len); iov = rqst[j].rq_iov;
dump_smb(iov[1].iov_base, iov[1].iov_len); n_vec = rqst[j].rq_nvec;
for (i = 0; i < n_vec; i++) cifs_dbg(FYI, "Sending smb: smb_len=%u\n", send_length);
size += iov[i].iov_len; dump_smb(iov[0].iov_base, iov[0].iov_len);
dump_smb(iov[1].iov_base, iov[1].iov_len);
iov_iter_kvec(&smb_msg.msg_iter, WRITE | ITER_KVEC, iov, n_vec, size); size = 0;
for (i = 0; i < n_vec; i++)
rc = smb_send_kvec(server, &smb_msg, &sent); size += iov[i].iov_len;
if (rc < 0)
goto uncork;
total_len += sent; iov_iter_kvec(&smb_msg.msg_iter, WRITE | ITER_KVEC,
iov, n_vec, size);
/* now walk the page array and send each page in it */
for (i = 0; i < rqst->rq_npages; i++) {
struct bio_vec bvec;
bvec.bv_page = rqst->rq_pages[i];
rqst_page_get_length(rqst, i, &bvec.bv_len, &bvec.bv_offset);
iov_iter_bvec(&smb_msg.msg_iter, WRITE | ITER_BVEC,
&bvec, 1, bvec.bv_len);
rc = smb_send_kvec(server, &smb_msg, &sent); rc = smb_send_kvec(server, &smb_msg, &sent);
if (rc < 0) if (rc < 0)
break; goto uncork;
total_len += sent; total_len += sent;
/* now walk the page array and send each page in it */
for (i = 0; i < rqst[j].rq_npages; i++) {
struct bio_vec bvec;
bvec.bv_page = rqst[j].rq_pages[i];
rqst_page_get_length(&rqst[j], i, &bvec.bv_len,
&bvec.bv_offset);
iov_iter_bvec(&smb_msg.msg_iter, WRITE | ITER_BVEC,
&bvec, 1, bvec.bv_len);
rc = smb_send_kvec(server, &smb_msg, &sent);
if (rc < 0)
break;
total_len += sent;
}
} }
uncork: uncork:
...@@ -344,7 +353,7 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags) ...@@ -344,7 +353,7 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags)
int rc; int rc;
if (!(flags & CIFS_TRANSFORM_REQ)) if (!(flags & CIFS_TRANSFORM_REQ))
return __smb_send_rqst(server, rqst); return __smb_send_rqst(server, 1, rqst);
if (!server->ops->init_transform_rq || if (!server->ops->init_transform_rq ||
!server->ops->free_transform_rq) { !server->ops->free_transform_rq) {
...@@ -356,7 +365,7 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags) ...@@ -356,7 +365,7 @@ smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags)
if (rc) if (rc)
return rc; return rc;
rc = __smb_send_rqst(server, &cur_rqst); rc = __smb_send_rqst(server, 1, &cur_rqst);
server->ops->free_transform_rq(&cur_rqst); server->ops->free_transform_rq(&cur_rqst);
return rc; return rc;
} }
...@@ -374,7 +383,7 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer, ...@@ -374,7 +383,7 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
iov[1].iov_base = (char *)smb_buffer + 4; iov[1].iov_base = (char *)smb_buffer + 4;
iov[1].iov_len = smb_buf_length; iov[1].iov_len = smb_buf_length;
return __smb_send_rqst(server, &rqst); return __smb_send_rqst(server, 1, &rqst);
} }
static int static int
......
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