aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenry C Chang <henry_c_chang@tcloudcomputing.com>2010-12-15 23:45:41 -0500
committerSage Weil <sage@newdream.net>2010-12-17 12:54:40 -0500
commitb6aa5901c7a2bd90d0b6b9866300d2648b2568f3 (patch)
tree1161ed9dbacb7ace73c5d48fc9acd1db0d7815d5
parent92cf765237e2787eb168096305c448caf25ac7f8 (diff)
ceph: mark user pages dirty on direct-io reads
For read operation, we have to set the argument _write_ of get_user_pages to 1 since we will write data to pages. Also, we need to SetPageDirty before releasing these pages. Signed-off-by: Henry C Chang <henry_c_chang@tcloudcomputing.com> Signed-off-by: Sage Weil <sage@newdream.net>
-rw-r--r--fs/ceph/file.c8
-rw-r--r--include/linux/ceph/libceph.h6
-rw-r--r--net/ceph/pagevec.c11
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
414done: 414done:
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);
227extern void ceph_release_page_vector(struct page **pages, int num_pages); 227extern void ceph_release_page_vector(struct page **pages, int num_pages);
228 228
229extern struct page **ceph_get_direct_page_vector(const char __user *data, 229extern struct page **ceph_get_direct_page_vector(const char __user *data,
230 int num_pages); 230 int num_pages,
231extern void ceph_put_page_vector(struct page **pages, int num_pages); 231 bool write_page);
232extern void ceph_put_page_vector(struct page **pages, int num_pages,
233 bool dirty);
232extern void ceph_release_page_vector(struct page **pages, int num_pages); 234extern void ceph_release_page_vector(struct page **pages, int num_pages);
233extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags); 235extern struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags);
234extern int ceph_copy_user_to_page_vector(struct page **pages, 236extern 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 */
15struct page **ceph_get_direct_page_vector(const char __user *data, 15struct 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(&current->mm->mmap_sem); 25 down_read(&current->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(&current->mm->mmap_sem); 28 up_read(&current->mm->mmap_sem);
29 if (rc < 0) 29 if (rc < 0)
30 goto fail; 30 goto fail;
@@ -36,12 +36,15 @@ fail:
36} 36}
37EXPORT_SYMBOL(ceph_get_direct_page_vector); 37EXPORT_SYMBOL(ceph_get_direct_page_vector);
38 38
39void ceph_put_page_vector(struct page **pages, int num_pages) 39void 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}
47EXPORT_SYMBOL(ceph_put_page_vector); 50EXPORT_SYMBOL(ceph_put_page_vector);