+static struct page **
+pages_vector_from_list(struct list_head *pages, unsigned nr_pages)
+{
+ struct page **pl;
+ struct page *t;
+ unsigned page_idx;
+
+ pl = kmalloc(sizeof(*pl) * nr_pages, GFP_NOFS);
+ if (!pl)
+ return ERR_PTR(-ENOMEM);
+
+ page_idx = 0;
+ list_for_each_entry_reverse(t, pages, lru) {
+ pl[page_idx] = t;
+ page_idx++;
+ }
+
+ return pl;
+}
+
+static int
+zpl_readpages(struct file *file, struct address_space *mapping,
+ struct list_head *pages, unsigned nr_pages)
+{
+ struct inode *ip;
+ struct page **pl;
+ struct page *p, *n;
+ int error;
+
+ ip = mapping->host;
+
+ pl = pages_vector_from_list(pages, nr_pages);
+ if (IS_ERR(pl))
+ return PTR_ERR(pl);
+
+ error = -zfs_getpage(ip, pl, nr_pages);
+ if (error)
+ goto error;
+
+ list_for_each_entry_safe_reverse(p, n, pages, lru) {
+
+ list_del(&p->lru);
+
+ flush_dcache_page(p);
+ SetPageUptodate(p);
+ unlock_page(p);
+ page_cache_release(p);
+ }
+
+error:
+ kfree(pl);
+ return error;
+}
+