Skip to content

Commit

Permalink
block: add a blk_steal_bios helper
Browse files Browse the repository at this point in the history
This helpers allows to bounce steal the uncompleted bios from a request so
that they can be reissued on another path.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and axboe committed Nov 3, 2017
1 parent f421e1d commit ef71de8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
21 changes: 21 additions & 0 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,27 @@ struct request *blk_fetch_request(struct request_queue *q)
}
EXPORT_SYMBOL(blk_fetch_request);

/*
* Steal bios from a request and add them to a bio list.
* The request must not have been partially completed before.
*/
void blk_steal_bios(struct bio_list *list, struct request *rq)
{
if (rq->bio) {
if (list->tail)
list->tail->bi_next = rq->bio;
else
list->head = rq->bio;
list->tail = rq->biotail;

rq->bio = NULL;
rq->biotail = NULL;
}

rq->__data_len = 0;
}
EXPORT_SYMBOL_GPL(blk_steal_bios);

/**
* blk_update_request - Special helper function for request stacking drivers
* @req: the request being processed
Expand Down
2 changes: 2 additions & 0 deletions include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,8 @@ extern struct request *blk_peek_request(struct request_queue *q);
extern void blk_start_request(struct request *rq);
extern struct request *blk_fetch_request(struct request_queue *q);

void blk_steal_bios(struct bio_list *list, struct request *rq);

/*
* Request completion related functions.
*
Expand Down

0 comments on commit ef71de8

Please sign in to comment.