.. | .. |
---|
10 | 10 | |
---|
11 | 11 | #include <linux/ceph/libceph.h> |
---|
12 | 12 | |
---|
13 | | -/* |
---|
14 | | - * build a vector of user pages |
---|
15 | | - */ |
---|
16 | | -struct page **ceph_get_direct_page_vector(const void __user *data, |
---|
17 | | - int num_pages, bool write_page) |
---|
18 | | -{ |
---|
19 | | - struct page **pages; |
---|
20 | | - int got = 0; |
---|
21 | | - int rc = 0; |
---|
22 | | - |
---|
23 | | - pages = kmalloc_array(num_pages, sizeof(*pages), GFP_NOFS); |
---|
24 | | - if (!pages) |
---|
25 | | - return ERR_PTR(-ENOMEM); |
---|
26 | | - |
---|
27 | | - while (got < num_pages) { |
---|
28 | | - rc = get_user_pages_fast( |
---|
29 | | - (unsigned long)data + ((unsigned long)got * PAGE_SIZE), |
---|
30 | | - num_pages - got, write_page, pages + got); |
---|
31 | | - if (rc < 0) |
---|
32 | | - break; |
---|
33 | | - BUG_ON(rc == 0); |
---|
34 | | - got += rc; |
---|
35 | | - } |
---|
36 | | - if (rc < 0) |
---|
37 | | - goto fail; |
---|
38 | | - return pages; |
---|
39 | | - |
---|
40 | | -fail: |
---|
41 | | - ceph_put_page_vector(pages, got, false); |
---|
42 | | - return ERR_PTR(rc); |
---|
43 | | -} |
---|
44 | | -EXPORT_SYMBOL(ceph_get_direct_page_vector); |
---|
45 | | - |
---|
46 | 13 | void ceph_put_page_vector(struct page **pages, int num_pages, bool dirty) |
---|
47 | 14 | { |
---|
48 | 15 | int i; |
---|