[3/9] cifs: make smb_send_rqst take an array of requests

Message ID 20180620011350.12328-4-lsahlber@redhat.com
State New
Headers show
Series
  • cifs: compounding
Related show

Commit Message

Ronnie Sahlberg June 20, 2018, 1:13 a.m.
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/transport.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

Patch

diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 6153b0d55704..43ce643c1aa4 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -349,10 +349,11 @@  __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 	return rc;
 }
 
-#define MAX_COMPOUND 2
+#define MAX_COMPOUND 5
 
 static int
-smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags)
+smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
+	      struct smb_rqst *rqst, int flags)
 {
 	struct kvec iov;
 	struct smb2_transform_hdr tr_hdr;
@@ -360,7 +361,10 @@  smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags)
 	int rc;
 
 	if (!(flags & CIFS_TRANSFORM_REQ))
-		return __smb_send_rqst(server, 1, rqst);
+		return __smb_send_rqst(server, num_rqst, rqst);
+
+	if (num_rqst > MAX_COMPOUND - 1)
+		return -ENOMEM;
 
 	memset(&cur_rqst[0], 0, sizeof(cur_rqst));
 	memset(&iov, 0, sizeof(iov));
@@ -373,16 +377,18 @@  smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags)
 	
 	if (!server->ops->init_transform_rq ||
 	    !server->ops->free_transform_rq) {
-		cifs_dbg(VFS, "Encryption requested but transform callbacks are missed\n");
+		cifs_dbg(VFS, "Encryption requested but transform callbacks "
+			 "are missed\n");
 		return -EIO;
 	}
 
-	rc = server->ops->init_transform_rq(server, 2, &cur_rqst[0], rqst);
+	rc = server->ops->init_transform_rq(server, num_rqst + 1,
+					    &cur_rqst[0], rqst);
 	if (rc)
 		return rc;
 
-	rc = __smb_send_rqst(server, 2, &cur_rqst[0]);
-	server->ops->free_transform_rq(2, &cur_rqst[0]);
+	rc = __smb_send_rqst(server, num_rqst + 1, &cur_rqst[0]);
+	server->ops->free_transform_rq(num_rqst + 1, &cur_rqst[0]);
 	return rc;
 }
 
@@ -596,7 +602,7 @@  cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
 	 */
 	cifs_save_when_sent(mid);
 	cifs_in_send_inc(server);
-	rc = smb_send_rqst(server, rqst, flags);
+	rc = smb_send_rqst(server, 1, rqst, flags);
 	cifs_in_send_dec(server);
 
 	if (rc < 0) {
@@ -786,7 +792,7 @@  cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
 
 	midQ->mid_state = MID_REQUEST_SUBMITTED;
 	cifs_in_send_inc(ses->server);
-	rc = smb_send_rqst(ses->server, rqst, flags);
+	rc = smb_send_rqst(ses->server, 1, rqst, flags);
 	cifs_in_send_dec(ses->server);
 	cifs_save_when_sent(midQ);