Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146975
b: refs/heads/master
c: 5efccd1
h: refs/heads/master
i:
  146973: b4016ac
  146971: ceb687d
  146967: 7ca1ef0
  146959: e1a7d44
  146943: 5d9e81e
v: v3
  • Loading branch information
Tejun Heo authored and Jens Axboe committed Apr 28, 2009
1 parent 14b3055 commit 5a212cc
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 81 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: 2eef33e439ba9ae387cdc3f1abcef2f3f6c4e7a8
refs/heads/master: 5efccd17ceb0fc43837a331297c2c407969d7201
144 changes: 72 additions & 72 deletions trunk/block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,35 @@ static void blk_account_io_done(struct request *req)
}
}

/**
* blk_rq_bytes - Returns bytes left to complete in the entire request
* @rq: the request being processed
**/
unsigned int blk_rq_bytes(struct request *rq)
{
if (blk_fs_request(rq))
return rq->hard_nr_sectors << 9;

return rq->data_len;
}
EXPORT_SYMBOL_GPL(blk_rq_bytes);

/**
* blk_rq_cur_bytes - Returns bytes left to complete in the current segment
* @rq: the request being processed
**/
unsigned int blk_rq_cur_bytes(struct request *rq)
{
if (blk_fs_request(rq))
return rq->current_nr_sectors << 9;

if (rq->bio)
return rq->bio->bi_size;

return rq->data_len;
}
EXPORT_SYMBOL_GPL(blk_rq_cur_bytes);

/**
* __end_that_request_first - end I/O on a request
* @req: the request being processed
Expand Down Expand Up @@ -1797,6 +1826,22 @@ static int __end_that_request_first(struct request *req, int error,
return 1;
}

static int end_that_request_data(struct request *rq, int error,
unsigned int nr_bytes, unsigned int bidi_bytes)
{
if (rq->bio) {
if (__end_that_request_first(rq, error, nr_bytes))
return 1;

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

return 0;
}

/*
* queue lock must be held
*/
Expand Down Expand Up @@ -1825,78 +1870,6 @@ static void end_that_request_last(struct request *req, int error)
}
}

/**
* blk_rq_bytes - Returns bytes left to complete in the entire request
* @rq: the request being processed
**/
unsigned int blk_rq_bytes(struct request *rq)
{
if (blk_fs_request(rq))
return rq->hard_nr_sectors << 9;

return rq->data_len;
}
EXPORT_SYMBOL_GPL(blk_rq_bytes);

/**
* blk_rq_cur_bytes - Returns bytes left to complete in the current segment
* @rq: the request being processed
**/
unsigned int blk_rq_cur_bytes(struct request *rq)
{
if (blk_fs_request(rq))
return rq->current_nr_sectors << 9;

if (rq->bio)
return rq->bio->bi_size;

return rq->data_len;
}
EXPORT_SYMBOL_GPL(blk_rq_cur_bytes);

/**
* end_request - end I/O on the current segment of the request
* @req: the request being processed
* @uptodate: error value or %0/%1 uptodate flag
*
* Description:
* Ends I/O on the current segment of a request. If that is the only
* remaining segment, the request is also completed and freed.
*
* This is a remnant of how older block drivers handled I/O completions.
* Modern drivers typically end I/O on the full request in one go, unless
* they have a residual value to account for. For that case this function
* isn't really useful, unless the residual just happens to be the
* full current segment. In other words, don't use this function in new
* code. Use blk_end_request() or __blk_end_request() to end a request.
**/
void end_request(struct request *req, int uptodate)
{
int error = 0;

if (uptodate <= 0)
error = uptodate ? uptodate : -EIO;

__blk_end_request(req, error, req->hard_cur_sectors << 9);
}
EXPORT_SYMBOL(end_request);

static int end_that_request_data(struct request *rq, int error,
unsigned int nr_bytes, unsigned int bidi_bytes)
{
if (rq->bio) {
if (__end_that_request_first(rq, error, nr_bytes))
return 1;

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

return 0;
}

/**
* blk_end_io - Generic end_io function to complete a request.
* @rq: the request being processed
Expand Down Expand Up @@ -2006,6 +1979,33 @@ int blk_end_bidi_request(struct request *rq, int error, unsigned int nr_bytes,
}
EXPORT_SYMBOL_GPL(blk_end_bidi_request);

/**
* end_request - end I/O on the current segment of the request
* @req: the request being processed
* @uptodate: error value or %0/%1 uptodate flag
*
* Description:
* Ends I/O on the current segment of a request. If that is the only
* remaining segment, the request is also completed and freed.
*
* This is a remnant of how older block drivers handled I/O completions.
* Modern drivers typically end I/O on the full request in one go, unless
* they have a residual value to account for. For that case this function
* isn't really useful, unless the residual just happens to be the
* full current segment. In other words, don't use this function in new
* code. Use blk_end_request() or __blk_end_request() to end a request.
**/
void end_request(struct request *req, int uptodate)
{
int error = 0;

if (uptodate <= 0)
error = uptodate ? uptodate : -EIO;

__blk_end_request(req, error, req->hard_cur_sectors << 9);
}
EXPORT_SYMBOL(end_request);

/**
* blk_update_request - Special helper function for request stacking drivers
* @rq: the request being processed
Expand Down
16 changes: 8 additions & 8 deletions trunk/include/linux/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,14 @@ static inline void blk_run_address_space(struct address_space *mapping)

extern void blkdev_dequeue_request(struct request *req);

/*
* blk_end_request() takes bytes instead of sectors as a complete size.
* blk_rq_bytes() returns bytes left to complete in the entire request.
* blk_rq_cur_bytes() returns bytes left to complete in the current segment.
*/
extern unsigned int blk_rq_bytes(struct request *rq);
extern unsigned int blk_rq_cur_bytes(struct request *rq);

/*
* blk_end_request() and friends.
* __blk_end_request() and end_request() must be called with
Expand All @@ -857,14 +865,6 @@ extern void blk_abort_queue(struct request_queue *);
extern void blk_update_request(struct request *rq, int error,
unsigned int nr_bytes);

/*
* blk_end_request() takes bytes instead of sectors as a complete size.
* blk_rq_bytes() returns bytes left to complete in the entire request.
* blk_rq_cur_bytes() returns bytes left to complete in the current segment.
*/
extern unsigned int blk_rq_bytes(struct request *rq);
extern unsigned int blk_rq_cur_bytes(struct request *rq);

/*
* Access functions for manipulating queue properties
*/
Expand Down

0 comments on commit 5a212cc

Please sign in to comment.