aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifssmb.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-09-18 19:20:35 -0400
committerSteve French <smfrench@gmail.com>2012-09-24 22:46:31 -0400
commiteddb079deb4deb1259f87425094c7a586fc59313 (patch)
treeca5c475cfd138a8e764673b0ecc2a54b4df2b7b3 /fs/cifs/cifssmb.c
parentfec344e3f31aa911297cd3a4639432d983b1f324 (diff)
cifs: convert async write code to pass in data via rq_pages array
Reviewed-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r--fs/cifs/cifssmb.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 2f86c84468cb..a110e0784221 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -2033,11 +2033,11 @@ cifs_writev_callback(struct mid_q_entry *mid)
2033int 2033int
2034cifs_async_writev(struct cifs_writedata *wdata) 2034cifs_async_writev(struct cifs_writedata *wdata)
2035{ 2035{
2036 int i, rc = -EACCES; 2036 int rc = -EACCES;
2037 WRITE_REQ *smb = NULL; 2037 WRITE_REQ *smb = NULL;
2038 int wct; 2038 int wct;
2039 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink); 2039 struct cifs_tcon *tcon = tlink_tcon(wdata->cfile->tlink);
2040 struct kvec *iov = NULL; 2040 struct kvec iov;
2041 struct smb_rqst rqst = { }; 2041 struct smb_rqst rqst = { };
2042 2042
2043 if (tcon->ses->capabilities & CAP_LARGE_FILES) { 2043 if (tcon->ses->capabilities & CAP_LARGE_FILES) {
@@ -2054,15 +2054,6 @@ cifs_async_writev(struct cifs_writedata *wdata)
2054 if (rc) 2054 if (rc)
2055 goto async_writev_out; 2055 goto async_writev_out;
2056 2056
2057 /* 1 iov per page + 1 for header */
2058 rqst.rq_nvec = wdata->nr_pages + 1;
2059 iov = kzalloc((rqst.rq_nvec) * sizeof(*iov), GFP_NOFS);
2060 if (iov == NULL) {
2061 rc = -ENOMEM;
2062 goto async_writev_out;
2063 }
2064 rqst.rq_iov = iov;
2065
2066 smb->hdr.Pid = cpu_to_le16((__u16)wdata->pid); 2057 smb->hdr.Pid = cpu_to_le16((__u16)wdata->pid);
2067 smb->hdr.PidHigh = cpu_to_le16((__u16)(wdata->pid >> 16)); 2058 smb->hdr.PidHigh = cpu_to_le16((__u16)(wdata->pid >> 16));
2068 2059
@@ -2079,18 +2070,15 @@ cifs_async_writev(struct cifs_writedata *wdata)
2079 cpu_to_le16(offsetof(struct smb_com_write_req, Data) - 4); 2070 cpu_to_le16(offsetof(struct smb_com_write_req, Data) - 4);
2080 2071
2081 /* 4 for RFC1001 length + 1 for BCC */ 2072 /* 4 for RFC1001 length + 1 for BCC */
2082 iov[0].iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4 + 1; 2073 iov.iov_len = be32_to_cpu(smb->hdr.smb_buf_length) + 4 + 1;
2083 iov[0].iov_base = smb; 2074 iov.iov_base = smb;
2084 2075
2085 /* 2076 rqst.rq_iov = &iov;
2086 * This function should marshal up the page array into the kvec 2077 rqst.rq_nvec = 1;
2087 * array, reserving [0] for the header. It should kmap the pages 2078 rqst.rq_pages = wdata->pages;
2088 * and set the iov_len properly for each one. It may also set 2079 rqst.rq_npages = wdata->nr_pages;
2089 * wdata->bytes too. 2080 rqst.rq_pagesz = wdata->pagesz;
2090 */ 2081 rqst.rq_tailsz = wdata->tailsz;
2091 cifs_kmap_lock();
2092 wdata->marshal_iov(iov, wdata);
2093 cifs_kmap_unlock();
2094 2082
2095 cFYI(1, "async write at %llu %u bytes", wdata->offset, wdata->bytes); 2083 cFYI(1, "async write at %llu %u bytes", wdata->offset, wdata->bytes);
2096 2084
@@ -2106,7 +2094,7 @@ cifs_async_writev(struct cifs_writedata *wdata)
2106 (struct smb_com_writex_req *)smb; 2094 (struct smb_com_writex_req *)smb;
2107 inc_rfc1001_len(&smbw->hdr, wdata->bytes + 5); 2095 inc_rfc1001_len(&smbw->hdr, wdata->bytes + 5);
2108 put_bcc(wdata->bytes + 5, &smbw->hdr); 2096 put_bcc(wdata->bytes + 5, &smbw->hdr);
2109 iov[0].iov_len += 4; /* pad bigger by four bytes */ 2097 iov.iov_len += 4; /* pad bigger by four bytes */
2110 } 2098 }
2111 2099
2112 kref_get(&wdata->refcount); 2100 kref_get(&wdata->refcount);
@@ -2118,13 +2106,8 @@ cifs_async_writev(struct cifs_writedata *wdata)
2118 else 2106 else
2119 kref_put(&wdata->refcount, cifs_writedata_release); 2107 kref_put(&wdata->refcount, cifs_writedata_release);
2120 2108
2121 /* send is done, unmap pages */
2122 for (i = 0; i < wdata->nr_pages; i++)
2123 kunmap(wdata->pages[i]);
2124
2125async_writev_out: 2109async_writev_out:
2126 cifs_small_buf_release(smb); 2110 cifs_small_buf_release(smb);
2127 kfree(iov);
2128 return rc; 2111 return rc;
2129} 2112}
2130 2113