Blame view
net/9p/trans_common.c
1.97 KB
022cae365 [net/9p] Preparat... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
/* * Copyright IBM Corporation, 2010 * Author Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of version 2.1 of the GNU Lesser General Public License * as published by the Free Software Foundation. * * This program is distributed in the hope that it would be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * */ #include <linux/slab.h> #include <linux/module.h> #include <net/9p/9p.h> #include <net/9p/client.h> #include <linux/scatterlist.h> #include "trans_common.h" /** * p9_release_req_pages - Release pages after the transaction. |
022cae365 [net/9p] Preparat... |
24 |
*/ |
abfa034e4 fs/9p: Update zer... |
25 |
void p9_release_pages(struct page **pages, int nr_pages) |
022cae365 [net/9p] Preparat... |
26 |
{ |
53effe169 9p: fix off by on... |
27 28 29 30 31 |
int i; for (i = 0; i < nr_pages; i++) if (pages[i]) put_page(pages[i]); |
022cae365 [net/9p] Preparat... |
32 |
} |
abfa034e4 fs/9p: Update zer... |
33 |
EXPORT_SYMBOL(p9_release_pages); |
022cae365 [net/9p] Preparat... |
34 35 |
/** |
25985edce Fix common misspe... |
36 |
* p9_nr_pages - Return number of pages needed to accommodate the payload. |
022cae365 [net/9p] Preparat... |
37 |
*/ |
abfa034e4 fs/9p: Update zer... |
38 |
int p9_nr_pages(char *data, int len) |
022cae365 [net/9p] Preparat... |
39 |
{ |
472e7f9f8 net/9p: Fix compi... |
40 |
unsigned long start_page, end_page; |
abfa034e4 fs/9p: Update zer... |
41 42 |
start_page = (unsigned long)data >> PAGE_SHIFT; end_page = ((unsigned long)data + len + PAGE_SIZE - 1) >> PAGE_SHIFT; |
022cae365 [net/9p] Preparat... |
43 44 45 46 47 48 49 50 51 52 |
return end_page - start_page; } EXPORT_SYMBOL(p9_nr_pages); /** * payload_gup - Translates user buffer into kernel pages and * pins them either for read/write through get_user_pages_fast(). * @req: Request to be sent to server. * @pdata_off: data offset into the first page after translation (gup). * @pdata_len: Total length of the IO. gup may not return requested # of pages. |
25985edce Fix common misspe... |
53 |
* @nr_pages: number of pages to accommodate the payload |
022cae365 [net/9p] Preparat... |
54 55 |
* @rw: Indicates if the pages are for read or write. */ |
022cae365 [net/9p] Preparat... |
56 |
|
abfa034e4 fs/9p: Update zer... |
57 58 59 |
int p9_payload_gup(char *data, int *nr_pages, struct page **pages, int write) { int nr_mapped_pages; |
022cae365 [net/9p] Preparat... |
60 |
|
abfa034e4 fs/9p: Update zer... |
61 62 63 64 |
nr_mapped_pages = get_user_pages_fast((unsigned long)data, *nr_pages, write, pages); if (nr_mapped_pages <= 0) return nr_mapped_pages; |
022cae365 [net/9p] Preparat... |
65 |
|
abfa034e4 fs/9p: Update zer... |
66 |
*nr_pages = nr_mapped_pages; |
022cae365 [net/9p] Preparat... |
67 68 69 |
return 0; } EXPORT_SYMBOL(p9_payload_gup); |