diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-15 12:03:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-15 12:03:47 -0400 |
commit | 23da64b4714812b66ecf010e7dfb3ed1bf2eda69 (patch) | |
tree | e2736bebc916cb540b0da83296d62b342612ecbd /include/linux/bio.h | |
parent | a23c218bd36e11120daf18e00a91d5dc20e288e6 (diff) | |
parent | a36e71f996e25d6213f57951f7ae1874086ec57e (diff) |
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
* 'for-linus' of git://git.kernel.dk/linux-2.6-block: (28 commits)
cfq-iosched: add close cooperator code
cfq-iosched: log responsible 'cfqq' in idle timer arm
cfq-iosched: tweak kick logic a bit more
cfq-iosched: no need to save interrupts in cfq_kick_queue()
brd: fix cacheflushing
brd: support barriers
swap: Remove code handling bio_alloc failure with __GFP_WAIT
gfs2: Remove code handling bio_alloc failure with __GFP_WAIT
ext4: Remove code handling bio_alloc failure with __GFP_WAIT
dio: Remove code handling bio_alloc failure with __GFP_WAIT
block: Remove code handling bio_alloc failure with __GFP_WAIT
bio: add documentation to bio_alloc()
splice: add helpers for locking pipe inode
splice: remove generic_file_splice_write_nolock()
ocfs2: fix i_mutex locking in ocfs2_splice_to_file()
splice: fix i_mutex locking in generic_splice_write()
splice: remove i_mutex locking in splice_from_pipe()
splice: split up __splice_from_pipe()
block: fix SG_IO to return a proper error value
cfq-iosched: don't delay queue kick for a merged request
...
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r-- | include/linux/bio.h | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index b900d2c67d29..b89cf2d82898 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -504,6 +504,115 @@ static inline int bio_has_data(struct bio *bio) | |||
504 | return bio && bio->bi_io_vec != NULL; | 504 | return bio && bio->bi_io_vec != NULL; |
505 | } | 505 | } |
506 | 506 | ||
507 | /* | ||
508 | * BIO list managment for use by remapping drivers (e.g. DM or MD). | ||
509 | * | ||
510 | * A bio_list anchors a singly-linked list of bios chained through the bi_next | ||
511 | * member of the bio. The bio_list also caches the last list member to allow | ||
512 | * fast access to the tail. | ||
513 | */ | ||
514 | struct bio_list { | ||
515 | struct bio *head; | ||
516 | struct bio *tail; | ||
517 | }; | ||
518 | |||
519 | static inline int bio_list_empty(const struct bio_list *bl) | ||
520 | { | ||
521 | return bl->head == NULL; | ||
522 | } | ||
523 | |||
524 | static inline void bio_list_init(struct bio_list *bl) | ||
525 | { | ||
526 | bl->head = bl->tail = NULL; | ||
527 | } | ||
528 | |||
529 | #define bio_list_for_each(bio, bl) \ | ||
530 | for (bio = (bl)->head; bio; bio = bio->bi_next) | ||
531 | |||
532 | static inline unsigned bio_list_size(const struct bio_list *bl) | ||
533 | { | ||
534 | unsigned sz = 0; | ||
535 | struct bio *bio; | ||
536 | |||
537 | bio_list_for_each(bio, bl) | ||
538 | sz++; | ||
539 | |||
540 | return sz; | ||
541 | } | ||
542 | |||
543 | static inline void bio_list_add(struct bio_list *bl, struct bio *bio) | ||
544 | { | ||
545 | bio->bi_next = NULL; | ||
546 | |||
547 | if (bl->tail) | ||
548 | bl->tail->bi_next = bio; | ||
549 | else | ||
550 | bl->head = bio; | ||
551 | |||
552 | bl->tail = bio; | ||
553 | } | ||
554 | |||
555 | static inline void bio_list_add_head(struct bio_list *bl, struct bio *bio) | ||
556 | { | ||
557 | bio->bi_next = bl->head; | ||
558 | |||
559 | bl->head = bio; | ||
560 | |||
561 | if (!bl->tail) | ||
562 | bl->tail = bio; | ||
563 | } | ||
564 | |||
565 | static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2) | ||
566 | { | ||
567 | if (!bl2->head) | ||
568 | return; | ||
569 | |||
570 | if (bl->tail) | ||
571 | bl->tail->bi_next = bl2->head; | ||
572 | else | ||
573 | bl->head = bl2->head; | ||
574 | |||
575 | bl->tail = bl2->tail; | ||
576 | } | ||
577 | |||
578 | static inline void bio_list_merge_head(struct bio_list *bl, | ||
579 | struct bio_list *bl2) | ||
580 | { | ||
581 | if (!bl2->head) | ||
582 | return; | ||
583 | |||
584 | if (bl->head) | ||
585 | bl2->tail->bi_next = bl->head; | ||
586 | else | ||
587 | bl->tail = bl2->tail; | ||
588 | |||
589 | bl->head = bl2->head; | ||
590 | } | ||
591 | |||
592 | static inline struct bio *bio_list_pop(struct bio_list *bl) | ||
593 | { | ||
594 | struct bio *bio = bl->head; | ||
595 | |||
596 | if (bio) { | ||
597 | bl->head = bl->head->bi_next; | ||
598 | if (!bl->head) | ||
599 | bl->tail = NULL; | ||
600 | |||
601 | bio->bi_next = NULL; | ||
602 | } | ||
603 | |||
604 | return bio; | ||
605 | } | ||
606 | |||
607 | static inline struct bio *bio_list_get(struct bio_list *bl) | ||
608 | { | ||
609 | struct bio *bio = bl->head; | ||
610 | |||
611 | bl->head = bl->tail = NULL; | ||
612 | |||
613 | return bio; | ||
614 | } | ||
615 | |||
507 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | 616 | #if defined(CONFIG_BLK_DEV_INTEGRITY) |
508 | 617 | ||
509 | #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) | 618 | #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) |