@@ -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 */