@@ -602,75 +602,11 @@ static inline unsigned bio_list_size(const struct bio_list *bl)
return sz;
}
-static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
-{
- bio->bi_next = NULL;
-
- if (bl->tail)
- bl->tail->bi_next = bio;
- else
- bl->head = bio;
-
- bl->tail = bio;
-}
-
-static inline void bio_list_add_head(struct bio_list *bl, struct bio *bio)
-{
- bio->bi_next = bl->head;
-
- bl->head = bio;
-
- if (!bl->tail)
- bl->tail = bio;
-}
-
-static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2)
-{
- if (!bl2->head)
- return;
-
- if (bl->tail)
- bl->tail->bi_next = bl2->head;
- else
- bl->head = bl2->head;
-
- bl->tail = bl2->tail;
-}
-
-static inline void bio_list_merge_head(struct bio_list *bl,
- struct bio_list *bl2)
-{
- if (!bl2->head)
- return;
-
- if (bl->head)
- bl2->tail->bi_next = bl->head;
- else
- bl->tail = bl2->tail;
-
- bl->head = bl2->head;
-}
-
static inline struct bio *bio_list_peek(struct bio_list *bl)
{
return bl->head;
}
-static inline struct bio *bio_list_pop(struct bio_list *bl)
-{
- struct bio *bio = bl->head;
-
- if (bio) {
- bl->head = bl->head->bi_next;
- if (!bl->head)
- bl->tail = NULL;
-
- bio->bi_next = NULL;
- }
-
- return bio;
-}
-
static inline struct bio *bio_list_get(struct bio_list *bl)
{
struct bio *bio = bl->head;
@@ -680,6 +616,74 @@ static inline struct bio *bio_list_get(struct bio_list *bl)
return bio;
}
+#define BIO_LIST_HELPERS(_pre, link) \
+ \
+static inline void _pre##_add(struct bio_list *bl, struct bio *bio) \
+{ \
+ bio->bi_##link = NULL; \
+ \
+ if (bl->tail) \
+ bl->tail->bi_##link = bio; \
+ else \
+ bl->head = bio; \
+ \
+ bl->tail = bio; \
+} \
+ \
+static inline void _pre##_add_head(struct bio_list *bl, struct bio *bio) \
+{ \
+ bio->bi_##link = bl->head; \
+ \
+ bl->head = bio; \
+ \
+ if (!bl->tail) \
+ bl->tail = bio; \
+} \
+ \
+static inline void _pre##_merge(struct bio_list *bl, struct bio_list *bl2) \
+{ \
+ if (!bl2->head) \
+ return; \
+ \
+ if (bl->tail) \
+ bl->tail->bi_##link = bl2->head; \
+ else \
+ bl->head = bl2->head; \
+ \
+ bl->tail = bl2->tail; \
+} \
+ \
+static inline void _pre##_merge_head(struct bio_list *bl, \
+ struct bio_list *bl2) \
+{ \
+ if (!bl2->head) \
+ return; \
+ \
+ if (bl->head) \
+ bl2->tail->bi_##link = bl->head; \
+ else \
+ bl->tail = bl2->tail; \
+ \
+ bl->head = bl2->head; \
+} \
+ \
+static inline struct bio *_pre##_pop(struct bio_list *bl) \
+{ \
+ struct bio *bio = bl->head; \
+ \
+ if (bio) { \
+ bl->head = bl->head->bi_##link; \
+ if (!bl->head) \
+ bl->tail = NULL; \
+ \
+ bio->bi_##link = NULL; \
+ } \
+ \
+ return bio; \
+} \
+
+BIO_LIST_HELPERS(bio_list, next);
+
/*
* Increment chain count for the bio. Make sure the CHAIN flag update
* is visible before the raised count.