diff options
Diffstat (limited to 'net/ceph/pagevec.c')
-rw-r--r-- | net/ceph/pagevec.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c index 54caf0687155..1a040e64c69f 100644 --- a/net/ceph/pagevec.c +++ b/net/ceph/pagevec.c | |||
@@ -13,8 +13,7 @@ | |||
13 | * build a vector of user pages | 13 | * build a vector of user pages |
14 | */ | 14 | */ |
15 | struct page **ceph_get_direct_page_vector(const char __user *data, | 15 | struct page **ceph_get_direct_page_vector(const char __user *data, |
16 | int num_pages, | 16 | int num_pages, bool write_page) |
17 | loff_t off, size_t len) | ||
18 | { | 17 | { |
19 | struct page **pages; | 18 | struct page **pages; |
20 | int rc; | 19 | int rc; |
@@ -25,24 +24,27 @@ struct page **ceph_get_direct_page_vector(const char __user *data, | |||
25 | 24 | ||
26 | down_read(¤t->mm->mmap_sem); | 25 | down_read(¤t->mm->mmap_sem); |
27 | rc = get_user_pages(current, current->mm, (unsigned long)data, | 26 | rc = get_user_pages(current, current->mm, (unsigned long)data, |
28 | num_pages, 0, 0, pages, NULL); | 27 | num_pages, write_page, 0, pages, NULL); |
29 | up_read(¤t->mm->mmap_sem); | 28 | up_read(¤t->mm->mmap_sem); |
30 | if (rc < 0) | 29 | if (rc < num_pages) |
31 | goto fail; | 30 | goto fail; |
32 | return pages; | 31 | return pages; |
33 | 32 | ||
34 | fail: | 33 | fail: |
35 | kfree(pages); | 34 | ceph_put_page_vector(pages, rc > 0 ? rc : 0, false); |
36 | return ERR_PTR(rc); | 35 | return ERR_PTR(rc); |
37 | } | 36 | } |
38 | EXPORT_SYMBOL(ceph_get_direct_page_vector); | 37 | EXPORT_SYMBOL(ceph_get_direct_page_vector); |
39 | 38 | ||
40 | void ceph_put_page_vector(struct page **pages, int num_pages) | 39 | void ceph_put_page_vector(struct page **pages, int num_pages, bool dirty) |
41 | { | 40 | { |
42 | int i; | 41 | int i; |
43 | 42 | ||
44 | for (i = 0; i < num_pages; i++) | 43 | for (i = 0; i < num_pages; i++) { |
44 | if (dirty) | ||
45 | set_page_dirty_lock(pages[i]); | ||
45 | put_page(pages[i]); | 46 | put_page(pages[i]); |
47 | } | ||
46 | kfree(pages); | 48 | kfree(pages); |
47 | } | 49 | } |
48 | EXPORT_SYMBOL(ceph_put_page_vector); | 50 | EXPORT_SYMBOL(ceph_put_page_vector); |