summaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-03-23 14:40:56 -0400
committerJeff Layton <jlayton@redhat.com>2012-03-23 14:40:56 -0400
commite9492871fb0546f1b73f309d9e8c0f030bfdfdca (patch)
treebe69a497fddd74de6b2f6ed18f525907a6dadab4 /fs/cifs/file.c
parenta7103b99e4cc00b9d40f6bad77389f9e2341820a (diff)
downloadlinux-e9492871fb0546f1b73f309d9e8c0f030bfdfdca.tar.bz2
cifs: abstract out function to marshal up the iovec array for async writes
We'll need to do something a bit different depending on the caller. Abstract the code that marshals the page array into an iovec. Signed-off-by: Jeff Layton <jlayton@redhat.com> Reviewed-by: Pavel Shilovsky <piastry@etersoft.ru>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 5633202b199c..58ac0f0512e7 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1648,6 +1648,27 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
return rc;
}
+/*
+ * Marshal up the iov array, reserving the first one for the header. Also,
+ * set wdata->bytes.
+ */
+static void
+cifs_writepages_marshal_iov(struct kvec *iov, struct cifs_writedata *wdata)
+{
+ int i;
+ struct inode *inode = wdata->cfile->dentry->d_inode;
+ loff_t size = i_size_read(inode);
+
+ /* marshal up the pages into iov array */
+ wdata->bytes = 0;
+ for (i = 0; i < wdata->nr_pages; i++) {
+ iov[i + 1].iov_len = min(size - page_offset(wdata->pages[i]),
+ (loff_t)PAGE_CACHE_SIZE);
+ iov[i + 1].iov_base = kmap(wdata->pages[i]);
+ wdata->bytes += iov[i + 1].iov_len;
+ }
+}
+
static int cifs_writepages(struct address_space *mapping,
struct writeback_control *wbc)
{
@@ -1792,6 +1813,7 @@ retry:
wdata->sync_mode = wbc->sync_mode;
wdata->nr_pages = nr_pages;
wdata->offset = page_offset(wdata->pages[0]);
+ wdata->marshal_iov = cifs_writepages_marshal_iov;
do {
if (wdata->cfile != NULL)