]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
cifs: replace kvec array in readdata with a single kvec
authorJeff Layton <jlayton@redhat.com>
Tue, 14 Aug 2012 18:39:45 +0000 (14:39 -0400)
committerSteve French <sfrench@us.ibm.com>
Fri, 14 Sep 2012 14:44:33 +0000 (09:44 -0500)
The array is no longer needed. We just need a single kvec to hold the
header for signature checking.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
fs/cifs/cifsglob.h
fs/cifs/cifssmb.c
fs/cifs/file.c
fs/cifs/smb2pdu.c

index 93e16200b2e8c9314b94bb517b1392013f373792..79e8b6f06021ee995ef80f3d10e0288306fe2151 100644 (file)
@@ -981,10 +981,9 @@ struct cifs_readdata {
        int (*read_into_pages)(struct TCP_Server_Info *server,
                                struct cifs_readdata *rdata,
                                unsigned int len);
+       struct kvec                     iov;
        unsigned int                    pagesz;
        unsigned int                    tailsz;
-       unsigned int                    nr_iov;
-       struct kvec                     *iov;
        unsigned int                    nr_pages;
        struct page                     *pages[];
 };
index 5d7bd757dcf1f961e334e95aaee2ffca0bd1db4d..88bbb3ef95b35ea2d3ba3d1cde66a4bd64a9e089 100644 (file)
@@ -1436,10 +1436,10 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
        len = min_t(unsigned int, buflen, server->vals->read_rsp_size) -
                                                        HEADER_SIZE(server) + 1;
 
-       rdata->iov[0].iov_base = buf + HEADER_SIZE(server) - 1;
-       rdata->iov[0].iov_len = len;
+       rdata->iov.iov_base = buf + HEADER_SIZE(server) - 1;
+       rdata->iov.iov_len = len;
 
-       length = cifs_readv_from_socket(server, rdata->iov, 1, len);
+       length = cifs_readv_from_socket(server, &rdata->iov, 1, len);
        if (length < 0)
                return length;
        server->total_read += length;
@@ -1485,20 +1485,19 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
        len = data_offset - server->total_read;
        if (len > 0) {
                /* read any junk before data into the rest of smallbuf */
-               rdata->iov[0].iov_base = buf + server->total_read;
-               rdata->iov[0].iov_len = len;
-               length = cifs_readv_from_socket(server, rdata->iov, 1, len);
+               rdata->iov.iov_base = buf + server->total_read;
+               rdata->iov.iov_len = len;
+               length = cifs_readv_from_socket(server, &rdata->iov, 1, len);
                if (length < 0)
                        return length;
                server->total_read += length;
        }
 
        /* set up first iov for signature check */
-       rdata->iov[0].iov_base = buf;
-       rdata->iov[0].iov_len = server->total_read;
-       rdata->nr_iov = 1;
+       rdata->iov.iov_base = buf;
+       rdata->iov.iov_len = server->total_read;
        cFYI(1, "0: iov_base=%p iov_len=%zu",
-               rdata->iov[0].iov_base, rdata->iov[0].iov_len);
+               rdata->iov.iov_base, rdata->iov.iov_len);
 
        /* how much data is in the response? */
        data_len = server->ops->read_data_length(buf);
@@ -1532,8 +1531,8 @@ cifs_readv_callback(struct mid_q_entry *mid)
        struct cifs_readdata *rdata = mid->callback_data;
        struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink);
        struct TCP_Server_Info *server = tcon->ses->server;
-       struct smb_rqst rqst = { .rq_iov = rdata->iov,
-                                .rq_nvec = rdata->nr_iov,
+       struct smb_rqst rqst = { .rq_iov = &rdata->iov,
+                                .rq_nvec = 1,
                                 .rq_pages = rdata->pages,
                                 .rq_npages = rdata->nr_pages,
                                 .rq_pagesz = rdata->pagesz,
@@ -1580,7 +1579,7 @@ cifs_async_readv(struct cifs_readdata *rdata)
        READ_REQ *smb = NULL;
        int wct;
        struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink);
-       struct smb_rqst rqst = { .rq_iov = rdata->iov,
+       struct smb_rqst rqst = { .rq_iov = &rdata->iov,
                                 .rq_nvec = 1 };
 
        cFYI(1, "%s: offset=%llu bytes=%u", __func__,
@@ -1621,8 +1620,8 @@ cifs_async_readv(struct cifs_readdata *rdata)
        }
 
        /* 4 for RFC1001 length + 1 for BCC */
-       rdata->iov[0].iov_base = smb;
-       rdata->iov[0].iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4;
+       rdata->iov.iov_base = smb;
+       rdata->iov.iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4;
 
        kref_get(&rdata->refcount);
        rc = cifs_call_async(tcon->ses->server, &rqst, cifs_readv_receive,
index c6a512af6276a627fbabe170081a44bb489c485b..d9dacca0b7dcb0fc474282fb6991cb9a789a34b0 100644 (file)
@@ -2413,11 +2413,6 @@ static struct cifs_readdata *
 cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete)
 {
        struct cifs_readdata *rdata;
-       struct kvec *iov;
-
-       iov = kzalloc(sizeof(*iov) * (nr_pages + 1), GFP_KERNEL);
-       if (!iov)
-               return (struct cifs_readdata *)iov;
 
        rdata = kzalloc(sizeof(*rdata) + (sizeof(struct page *) * nr_pages),
                        GFP_KERNEL);
@@ -2426,9 +2421,6 @@ cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete)
                INIT_LIST_HEAD(&rdata->list);
                init_completion(&rdata->done);
                INIT_WORK(&rdata->work, complete);
-               rdata->iov = iov;
-       } else {
-               kfree(iov);
        }
 
        return rdata;
@@ -2443,7 +2435,6 @@ cifs_readdata_release(struct kref *refcount)
        if (rdata->cfile)
                cifsFileInfo_put(rdata->cfile);
 
-       kfree(rdata->iov);
        kfree(rdata);
 }
 
index e3efa47cd6ec8feda2d132a57acb6042c36bb780..1b447612200e214b40e433568aeeb5610026e2e1 100644 (file)
@@ -1297,9 +1297,9 @@ smb2_readv_callback(struct mid_q_entry *mid)
        struct cifs_readdata *rdata = mid->callback_data;
        struct cifs_tcon *tcon = tlink_tcon(rdata->cfile->tlink);
        struct TCP_Server_Info *server = tcon->ses->server;
-       struct smb2_hdr *buf = (struct smb2_hdr *)rdata->iov[0].iov_base;
+       struct smb2_hdr *buf = (struct smb2_hdr *)rdata->iov.iov_base;
        unsigned int credits_received = 1;
-       struct smb_rqst rqst = { .rq_iov = rdata->iov,
+       struct smb_rqst rqst = { .rq_iov = &rdata->iov,
                                 .rq_nvec = 1,
                                 .rq_pages = rdata->pages,
                                 .rq_npages = rdata->nr_pages,
@@ -1350,7 +1350,7 @@ smb2_async_readv(struct cifs_readdata *rdata)
        int rc;
        struct smb2_hdr *buf;
        struct cifs_io_parms io_parms;
-       struct smb_rqst rqst = { .rq_iov = rdata->iov,
+       struct smb_rqst rqst = { .rq_iov = &rdata->iov,
                                 .rq_nvec = 1 };
 
        cFYI(1, "%s: offset=%llu bytes=%u", __func__,
@@ -1362,13 +1362,13 @@ smb2_async_readv(struct cifs_readdata *rdata)
        io_parms.persistent_fid = rdata->cfile->fid.persistent_fid;
        io_parms.volatile_fid = rdata->cfile->fid.volatile_fid;
        io_parms.pid = rdata->pid;
-       rc = smb2_new_read_req(&rdata->iov[0], &io_parms, 0, 0);
+       rc = smb2_new_read_req(&rdata->iov, &io_parms, 0, 0);
        if (rc)
                return rc;
 
-       buf = (struct smb2_hdr *)rdata->iov[0].iov_base;
+       buf = (struct smb2_hdr *)rdata->iov.iov_base;
        /* 4 for rfc1002 length field */
-       rdata->iov[0].iov_len = get_rfc1002_length(rdata->iov[0].iov_base) + 4;
+       rdata->iov.iov_len = get_rfc1002_length(rdata->iov.iov_base) + 4;
 
        kref_get(&rdata->refcount);
        rc = cifs_call_async(io_parms.tcon->ses->server, &rqst,