aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-05-16 07:13:16 -0400
committerSteve French <sfrench@us.ibm.com>2012-05-16 21:13:29 -0400
commit0471ca3fe481cf5ff0ae24c7003f4d9086a02791 (patch)
treed3d5abc60b7a932210f43fe730f54d3f5359cc3e /fs/cifs/file.c
parent0e93b4b304ae052ba1bc73f6d34a68556fe93429 (diff)
cifs: make cifs_readdata_alloc take a work_func_t arg
We'll need different completion routines for an uncached read. Allow the caller to set the one he needs at allocation time. Also, move most of these functions to file.c so we can make more of them static. Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 81725e9286e9..d210288e4a47 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2339,6 +2339,27 @@ ssize_t cifs_strict_writev(struct kiocb *iocb, const struct iovec *iov,
2339 return cifs_user_writev(iocb, iov, nr_segs, pos); 2339 return cifs_user_writev(iocb, iov, nr_segs, pos);
2340} 2340}
2341 2341
2342static struct cifs_readdata *
2343cifs_readdata_alloc(unsigned int nr_vecs, work_func_t complete)
2344{
2345 struct cifs_readdata *rdata;
2346
2347 rdata = kzalloc(sizeof(*rdata) +
2348 sizeof(struct kvec) * nr_vecs, GFP_KERNEL);
2349 if (rdata != NULL) {
2350 INIT_WORK(&rdata->work, complete);
2351 INIT_LIST_HEAD(&rdata->pages);
2352 }
2353 return rdata;
2354}
2355
2356static void
2357cifs_readdata_free(struct cifs_readdata *rdata)
2358{
2359 cifsFileInfo_put(rdata->cfile);
2360 kfree(rdata);
2361}
2362
2342static ssize_t 2363static ssize_t
2343cifs_iovec_read(struct file *file, const struct iovec *iov, 2364cifs_iovec_read(struct file *file, const struct iovec *iov,
2344 unsigned long nr_segs, loff_t *poffset) 2365 unsigned long nr_segs, loff_t *poffset)
@@ -2606,6 +2627,33 @@ int cifs_file_mmap(struct file *file, struct vm_area_struct *vma)
2606 return rc; 2627 return rc;
2607} 2628}
2608 2629
2630static void
2631cifs_readv_complete(struct work_struct *work)
2632{
2633 struct cifs_readdata *rdata = container_of(work,
2634 struct cifs_readdata, work);
2635 struct page *page, *tpage;
2636
2637 list_for_each_entry_safe(page, tpage, &rdata->pages, lru) {
2638 list_del(&page->lru);
2639 lru_cache_add_file(page);
2640
2641 if (rdata->result == 0) {
2642 kunmap(page);
2643 flush_dcache_page(page);
2644 SetPageUptodate(page);
2645 }
2646
2647 unlock_page(page);
2648
2649 if (rdata->result == 0)
2650 cifs_readpage_to_fscache(rdata->mapping->host, page);
2651
2652 page_cache_release(page);
2653 }
2654 cifs_readdata_free(rdata);
2655}
2656
2609static int cifs_readpages(struct file *file, struct address_space *mapping, 2657static int cifs_readpages(struct file *file, struct address_space *mapping,
2610 struct list_head *page_list, unsigned num_pages) 2658 struct list_head *page_list, unsigned num_pages)
2611{ 2659{
@@ -2708,7 +2756,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
2708 nr_pages++; 2756 nr_pages++;
2709 } 2757 }
2710 2758
2711 rdata = cifs_readdata_alloc(nr_pages); 2759 rdata = cifs_readdata_alloc(nr_pages, cifs_readv_complete);
2712 if (!rdata) { 2760 if (!rdata) {
2713 /* best to give up if we're out of mem */ 2761 /* best to give up if we're out of mem */
2714 list_for_each_entry_safe(page, tpage, &tmplist, lru) { 2762 list_for_each_entry_safe(page, tpage, &tmplist, lru) {