Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
422 | giacomo | 1 | /* |
2 | * include/linux/pagevec.h |
||
3 | * |
||
4 | * In many places it is efficient to batch an operation up against multiple |
||
5 | * pages. A pagevec is a multipage container which is used for that. |
||
6 | */ |
||
7 | |||
8 | #define PAGEVEC_SIZE 16 |
||
9 | |||
10 | struct page; |
||
11 | struct address_space; |
||
12 | |||
13 | struct pagevec { |
||
14 | unsigned nr; |
||
15 | int cold; |
||
16 | struct page *pages[PAGEVEC_SIZE]; |
||
17 | }; |
||
18 | |||
19 | void __pagevec_release(struct pagevec *pvec); |
||
20 | void __pagevec_release_nonlru(struct pagevec *pvec); |
||
21 | void __pagevec_free(struct pagevec *pvec); |
||
22 | void __pagevec_lru_add(struct pagevec *pvec); |
||
23 | void __pagevec_lru_add_active(struct pagevec *pvec); |
||
24 | void pagevec_strip(struct pagevec *pvec); |
||
25 | unsigned int pagevec_lookup(struct pagevec *pvec, struct address_space *mapping, |
||
26 | pgoff_t start, unsigned int nr_pages); |
||
27 | |||
28 | static inline void pagevec_init(struct pagevec *pvec, int cold) |
||
29 | { |
||
30 | pvec->nr = 0; |
||
31 | pvec->cold = cold; |
||
32 | } |
||
33 | |||
34 | static inline void pagevec_reinit(struct pagevec *pvec) |
||
35 | { |
||
36 | pvec->nr = 0; |
||
37 | } |
||
38 | |||
39 | static inline unsigned pagevec_count(struct pagevec *pvec) |
||
40 | { |
||
41 | return pvec->nr; |
||
42 | } |
||
43 | |||
44 | static inline unsigned pagevec_space(struct pagevec *pvec) |
||
45 | { |
||
46 | return PAGEVEC_SIZE - pvec->nr; |
||
47 | } |
||
48 | |||
49 | /* |
||
50 | * Add a page to a pagevec. Returns the number of slots still available. |
||
51 | */ |
||
52 | static inline unsigned pagevec_add(struct pagevec *pvec, struct page *page) |
||
53 | { |
||
54 | pvec->pages[pvec->nr++] = page; |
||
55 | return pagevec_space(pvec); |
||
56 | } |
||
57 | |||
58 | |||
59 | static inline void pagevec_release(struct pagevec *pvec) |
||
60 | { |
||
61 | if (pagevec_count(pvec)) |
||
62 | __pagevec_release(pvec); |
||
63 | } |
||
64 | |||
65 | static inline void pagevec_release_nonlru(struct pagevec *pvec) |
||
66 | { |
||
67 | if (pagevec_count(pvec)) |
||
68 | __pagevec_release_nonlru(pvec); |
||
69 | } |
||
70 | |||
71 | static inline void pagevec_free(struct pagevec *pvec) |
||
72 | { |
||
73 | if (pagevec_count(pvec)) |
||
74 | __pagevec_free(pvec); |
||
75 | } |
||
76 | |||
77 | static inline void pagevec_lru_add(struct pagevec *pvec) |
||
78 | { |
||
79 | if (pagevec_count(pvec)) |
||
80 | __pagevec_lru_add(pvec); |
||
81 | } |