Skip to content

Commit 0ba6993

Browse files
Heinz MauelshagenLinus Torvalds
authored andcommitted
dm: bio list helpers
More bio_list helper functions for new targets (including dm-delay and dm-loop) to manipulate lists of bios. Signed-off-by: Heinz Mauelshagen <hjm@redhat.com> Signed-off-by: Bryn Reeves <breeves@redhat.com> Signed-off-by: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent bf17ce3 commit 0ba6993

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/md/dm-bio-list.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,43 @@
88
#define DM_BIO_LIST_H
99

1010
#include <linux/bio.h>
11+
#include <linux/prefetch.h>
1112

1213
struct bio_list {
1314
struct bio *head;
1415
struct bio *tail;
1516
};
1617

18+
static inline int bio_list_empty(const struct bio_list *bl)
19+
{
20+
return bl->head == NULL;
21+
}
22+
23+
#define BIO_LIST_INIT { .head = NULL, .tail = NULL }
24+
25+
#define BIO_LIST(bl) \
26+
struct bio_list bl = BIO_LIST_INIT
27+
1728
static inline void bio_list_init(struct bio_list *bl)
1829
{
1930
bl->head = bl->tail = NULL;
2031
}
2132

33+
#define bio_list_for_each(bio, bl) \
34+
for (bio = (bl)->head; bio && ({ prefetch(bio->bi_next); 1; }); \
35+
bio = bio->bi_next)
36+
37+
static inline unsigned bio_list_size(const struct bio_list *bl)
38+
{
39+
unsigned sz = 0;
40+
struct bio *bio;
41+
42+
bio_list_for_each(bio, bl)
43+
sz++;
44+
45+
return sz;
46+
}
47+
2248
static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
2349
{
2450
bio->bi_next = NULL;

0 commit comments

Comments
 (0)