summaryrefslogtreecommitdiffstats
path: root/net/ceph/pagevec.c
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2011-03-03 01:55:21 +0100
committerSage Weil <sage@newdream.net>2011-03-03 22:47:39 +0100
commit38815b780285a4957852c5c9dbe94991c0b26c56 (patch)
tree032d882544ef73d2e99208de7a6e6340df3d31ea /net/ceph/pagevec.c
parentceph: do not clear I_COMPLETE from d_release (diff)
downloadlinux-38815b780285a4957852c5c9dbe94991c0b26c56.tar.xz
linux-38815b780285a4957852c5c9dbe94991c0b26c56.zip
libceph: fix handling of short returns from get_user_pages
get_user_pages() can return fewer pages than we ask for. We were returning a bogus pointer/error code in that case. Instead, loop until we get all the pages we want or get an error we can return to the caller. Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to '')
-rw-r--r--net/ceph/pagevec.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c
index 1a040e64c69f..cd9c21df87d1 100644
--- a/net/ceph/pagevec.c
+++ b/net/ceph/pagevec.c
@@ -16,22 +16,30 @@ struct page **ceph_get_direct_page_vector(const char __user *data,
int num_pages, bool write_page)
{
struct page **pages;
- int rc;
+ int got = 0;
+ int rc = 0;
pages = kmalloc(sizeof(*pages) * num_pages, GFP_NOFS);
if (!pages)
return ERR_PTR(-ENOMEM);
down_read(&current->mm->mmap_sem);
- rc = get_user_pages(current, current->mm, (unsigned long)data,
- num_pages, write_page, 0, pages, NULL);
+ while (got < num_pages) {
+ rc = get_user_pages(current, current->mm,
+ (unsigned long)data + ((unsigned long)got * PAGE_SIZE),
+ num_pages - got, write_page, 0, pages + got, NULL);
+ if (rc < 0)
+ break;
+ BUG_ON(rc == 0);
+ got += rc;
+ }
up_read(&current->mm->mmap_sem);
- if (rc < num_pages)
+ if (rc < 0)
goto fail;
return pages;
fail:
- ceph_put_page_vector(pages, rc > 0 ? rc : 0, false);
+ ceph_put_page_vector(pages, got, false);
return ERR_PTR(rc);
}
EXPORT_SYMBOL(ceph_get_direct_page_vector);