From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> There's plenty of space in the pagevec for a loop counter, and that will come in handy later. Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> --- include/linux/pagevec.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index 081d934eda64..9b8c43661ab3 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -19,6 +19,7 @@ struct address_space; struct pagevec { unsigned char nr; + unsigned char first; bool percpu_pvec_drained; struct page *pages[PAGEVEC_SIZE]; }; @@ -55,12 +56,14 @@ static inline unsigned pagevec_lookup_tag(struct pagevec *pvec, static inline void pagevec_init(struct pagevec *pvec) { pvec->nr = 0; + pvec->first = 0; pvec->percpu_pvec_drained = false; } static inline void pagevec_reinit(struct pagevec *pvec) { pvec->nr = 0; + pvec->first = 0; } static inline unsigned pagevec_count(struct pagevec *pvec) @@ -88,4 +91,21 @@ static inline void pagevec_release(struct pagevec *pvec) __pagevec_release(pvec); } +static inline struct page *pagevec_last(struct pagevec *pvec) +{ + if (pvec->nr == 0) + return NULL; + return pvec->pages[pvec->nr - 1]; +} + +static inline struct page *pagevec_next(struct pagevec *pvec) +{ + if (pvec->first >= pvec->nr) + return NULL; + return pvec->pages[pvec->first++]; +} + +#define pagevec_for_each(pvec, page) \ + while ((page = pagevec_next(pvec))) + #endif /* _LINUX_PAGEVEC_H */ -- 2.24.1