diff options
-rw-r--r-- | fs/ceph/file.c | 8 | ||||
-rw-r--r-- | include/linux/ceph/libceph.h | 6 | ||||
-rw-r--r-- | net/ceph/pagevec.c | 11 |
3 files changed, 15 insertions, 10 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c index e860d8f1bb45..7d0e4a82d898 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c | |||
@@ -384,7 +384,7 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data, | |||
384 | 384 | ||
385 | if (file->f_flags & O_DIRECT) { | 385 | if (file->f_flags & O_DIRECT) { |
386 | num_pages = calc_pages_for((unsigned long)data, len); | 386 | num_pages = calc_pages_for((unsigned long)data, len); |
387 | pages = ceph_get_direct_page_vector(data, num_pages); | 387 | pages = ceph_get_direct_page_vector(data, num_pages, true); |
388 | } else { | 388 | } else { |
389 | num_pages = calc_pages_for(off, len); | 389 | num_pages = calc_pages_for(off, len); |
390 | pages = ceph_alloc_page_vector(num_pages, GFP_NOFS); | 390 | pages = ceph_alloc_page_vector(num_pages, GFP_NOFS); |
@@ -413,7 +413,7 @@ static ssize_t ceph_sync_read(struct file *file, char __user *data, | |||
413 | 413 | ||
414 | done: | 414 | done: |
415 | if (file->f_flags & O_DIRECT) | 415 | if (file->f_flags & O_DIRECT) |
416 | ceph_put_page_vector(pages, num_pages); | 416 | ceph_put_page_vector(pages, num_pages, true); |
417 | else | 417 | else |
418 | ceph_release_page_vector(pages, num_pages); | 418 | ceph_release_page_vector(pages, num_pages); |
419 | dout("sync_read result %d\n", ret); | 419 | dout("sync_read result %d\n", ret); |
@@ -522,7 +522,7 @@ more: | |||
522 | return -ENOMEM; | 522 | return -ENOMEM; |
523 | 523 | ||
524 | if (file->f_flags & O_DIRECT) { | 524 | if (file->f_flags & O_DIRECT) { |
525 | pages = ceph_get_direct_page_vector(data, num_pages); | 525 | pages = ceph_get_direct_page_vector(data, num_pages, false); |
526 | if (IS_ERR(pages)) { | 526 | if (IS_ERR(pages)) { |
527 | ret = PTR_ERR(pages); | 527 | ret = PTR_ERR(pages); |
528 | goto out; | 528 | goto out; |
@@ -572,7 +572,7 @@ more: | |||
572 | } | 572 | } |
573 | 573 | ||
574 | if (file->f_flags & O_DIRECT) | 574 | if (file->f_flags & O_DIRECT) |
575 | ceph_put_page_vector(pages, num_pages); | 575 | ceph_put_page_vector(pages, num_pages, false); |
576 | else if (file->f_flags & O_SYNC) | 576 | else if (file->f_flags & O_SYNC) |
577 | ceph_release_page_vector(pages, num_pages); | 577 | ceph_release_page_vector(pages, num_pages); |
578 | 578 | ||
diff --git a/include/linux/ceph/libceph.h b/include/linux/ceph/libceph.h index 9e76d35670d2..72c72bfccb88 100644 --- a/include/linux/ceph/libceph.h +++ b/include/linux/ceph/libceph.h | |||
@@ -227,8 +227,10 @@ extern int ceph_open_session(struct ceph_client *client); | |||
227 | extern void ceph_release_page_vector(struct page **pages, int num_pages); | 227 | extern void ceph_release_page_vector(struct page **pages, int num_pages); |
228 | 228 | ||
229 | extern struct page **ceph_get_direct_page_vector(const char __user *data, | 229 | extern struct page **ceph_get_direct_page_vector(const char __user *data, |
230 | int num_pages); | 230 | int num_pages, |
231 | extern void ceph_put_page_vector(struct page **pages, int num_pages); | 231 | bool write_page); |
232 | extern void ceph_put_page_vector(struct page **pages, int num_pages, | ||
233 | bool dirty); | ||
232 | extern void ceph_release_page_vector(struct page **pages, int num_pages); | 234 | extern void ceph_release_page_vector(struct page **pages, int num_pages); |
233 | extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags); | 235 | extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags); |
234 | extern int ceph_copy_user_to_page_vector(struct page **pages, | 236 | extern int ceph_copy_user_to_page_vector(struct page **pages, |
diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c index ac34feeb2b3a..01947a5d03b7 100644 --- a/net/ceph/pagevec.c +++ b/net/ceph/pagevec.c | |||
@@ -13,7 +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 | { | 17 | { |
18 | struct page **pages; | 18 | struct page **pages; |
19 | int rc; | 19 | int rc; |
@@ -24,7 +24,7 @@ struct page **ceph_get_direct_page_vector(const char __user *data, | |||
24 | 24 | ||
25 | down_read(¤t->mm->mmap_sem); | 25 | down_read(¤t->mm->mmap_sem); |
26 | rc = get_user_pages(current, current->mm, (unsigned long)data, | 26 | rc = get_user_pages(current, current->mm, (unsigned long)data, |
27 | num_pages, 0, 0, pages, NULL); | 27 | num_pages, write_page, 0, pages, NULL); |
28 | up_read(¤t->mm->mmap_sem); | 28 | up_read(¤t->mm->mmap_sem); |
29 | if (rc < 0) | 29 | if (rc < 0) |
30 | goto fail; | 30 | goto fail; |
@@ -36,12 +36,15 @@ fail: | |||
36 | } | 36 | } |
37 | EXPORT_SYMBOL(ceph_get_direct_page_vector); | 37 | EXPORT_SYMBOL(ceph_get_direct_page_vector); |
38 | 38 | ||
39 | 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) |
40 | { | 40 | { |
41 | int i; | 41 | int i; |
42 | 42 | ||
43 | 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]); | ||
44 | put_page(pages[i]); | 46 | put_page(pages[i]); |
47 | } | ||
45 | kfree(pages); | 48 | kfree(pages); |
46 | } | 49 | } |
47 | EXPORT_SYMBOL(ceph_put_page_vector); | 50 | EXPORT_SYMBOL(ceph_put_page_vector); |