Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77628
b: refs/heads/master
c: e3a04fe
h: refs/heads/master
v: v3
  • Loading branch information
Kiyoshi Ueda authored and Jens Axboe committed Jan 28, 2008
1 parent 000e28c commit 5208e67
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aaa04c28cb9a1efd42541fdb7ab648231c2a2263
refs/heads/master: e3a04fe34a3ec81ddeddb6c73fb7299716cffbb0
40 changes: 35 additions & 5 deletions trunk/block/ll_rw_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3821,29 +3821,33 @@ static void complete_request(struct request *rq, int error)
if (blk_queued_rq(rq))
blkdev_dequeue_request(rq);

if (blk_bidi_rq(rq) && !rq->end_io)
__blk_put_request(rq->next_rq->q, rq->next_rq);

end_that_request_last(rq, uptodate);
}

/**
* blk_end_io - Generic end_io function to complete a request.
* @rq: the request being processed
* @error: 0 for success, < 0 for error
* @nr_bytes: number of bytes to complete
* @nr_bytes: number of bytes to complete @rq
* @bidi_bytes: number of bytes to complete @rq->next_rq
* @drv_callback: function called between completion of bios in the request
* and completion of the request.
* If the callback returns non 0, this helper returns without
* completion of the request.
*
* Description:
* Ends I/O on a number of bytes attached to @rq.
* Ends I/O on a number of bytes attached to @rq and @rq->next_rq.
* If @rq has leftover, sets it up for the next range of segments.
*
* Return:
* 0 - we are done with this request
* 1 - this request is not freed yet, it still has pending buffers.
**/
static int blk_end_io(struct request *rq, int error, int nr_bytes,
int (drv_callback)(struct request *))
int bidi_bytes, int (drv_callback)(struct request *))
{
struct request_queue *q = rq->q;
unsigned long flags = 0UL;
Expand All @@ -3858,6 +3862,11 @@ static int blk_end_io(struct request *rq, int error, int nr_bytes,
if (blk_fs_request(rq) || blk_pc_request(rq)) {
if (__end_that_request_first(rq, uptodate, nr_bytes))
return 1;

/* Bidi request must be completed as a whole */
if (blk_bidi_rq(rq) &&
__end_that_request_first(rq->next_rq, uptodate, bidi_bytes))
return 1;
}

/* Special feature for tricky drivers */
Expand Down Expand Up @@ -3889,7 +3898,7 @@ static int blk_end_io(struct request *rq, int error, int nr_bytes,
**/
int blk_end_request(struct request *rq, int error, int nr_bytes)
{
return blk_end_io(rq, error, nr_bytes, NULL);
return blk_end_io(rq, error, nr_bytes, 0, NULL);
}
EXPORT_SYMBOL_GPL(blk_end_request);

Expand Down Expand Up @@ -3929,6 +3938,27 @@ int __blk_end_request(struct request *rq, int error, int nr_bytes)
}
EXPORT_SYMBOL_GPL(__blk_end_request);

/**
* blk_end_bidi_request - Helper function for drivers to complete bidi request.
* @rq: the bidi request being processed
* @error: 0 for success, < 0 for error
* @nr_bytes: number of bytes to complete @rq
* @bidi_bytes: number of bytes to complete @rq->next_rq
*
* Description:
* Ends I/O on a number of bytes attached to @rq and @rq->next_rq.
*
* Return:
* 0 - we are done with this request
* 1 - still buffers pending for this request
**/
int blk_end_bidi_request(struct request *rq, int error, int nr_bytes,
int bidi_bytes)
{
return blk_end_io(rq, error, nr_bytes, bidi_bytes, NULL);
}
EXPORT_SYMBOL_GPL(blk_end_bidi_request);

/**
* blk_end_request_callback - Special helper function for tricky drivers
* @rq: the request being processed
Expand Down Expand Up @@ -3957,7 +3987,7 @@ EXPORT_SYMBOL_GPL(__blk_end_request);
int blk_end_request_callback(struct request *rq, int error, int nr_bytes,
int (drv_callback)(struct request *))
{
return blk_end_io(rq, error, nr_bytes, drv_callback);
return blk_end_io(rq, error, nr_bytes, 0, drv_callback);
}
EXPORT_SYMBOL_GPL(blk_end_request_callback);

Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,8 @@ static inline void blk_run_address_space(struct address_space *mapping)
*/
extern int blk_end_request(struct request *rq, int error, int nr_bytes);
extern int __blk_end_request(struct request *rq, int error, int nr_bytes);
extern int blk_end_bidi_request(struct request *rq, int error, int nr_bytes,
int bidi_bytes);
extern int end_that_request_first(struct request *, int, int);
extern int end_that_request_chunk(struct request *, int, int);
extern void end_that_request_last(struct request *, int);
Expand Down

0 comments on commit 5208e67

Please sign in to comment.