block: reorder request completion functions
Reorder request completion functions such that * All request completion functions are located together. * Functions which are used by only one caller is put right above the caller. * end_request() is put after other completion functions but before blk_update_request(). This change is for completion function cleanup which will follow. [ Impact: cleanup, code reorganization ] Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
144
block/blk-core.c
144
block/blk-core.c
@@ -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
|
* __end_that_request_first - end I/O on a request
|
||||||
* @req: the request being processed
|
* @req: the request being processed
|
||||||
@@ -1797,6 +1826,22 @@ static int __end_that_request_first(struct request *req, int error,
|
|||||||
return 1;
|
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
|
* queue lock must be held
|
||||||
*/
|
*/
|
||||||
@@ -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.
|
* blk_end_io - Generic end_io function to complete a request.
|
||||||
* @rq: the request being processed
|
* @rq: the request being processed
|
||||||
@@ -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);
|
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
|
* blk_update_request - Special helper function for request stacking drivers
|
||||||
* @rq: the request being processed
|
* @rq: the request being processed
|
||||||
|
@@ -831,6 +831,14 @@ static inline void blk_run_address_space(struct address_space *mapping)
|
|||||||
|
|
||||||
extern void blkdev_dequeue_request(struct request *req);
|
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 friends.
|
||||||
* __blk_end_request() and end_request() must be called with
|
* __blk_end_request() and end_request() must be called with
|
||||||
@@ -857,14 +865,6 @@ extern void blk_abort_queue(struct request_queue *);
|
|||||||
extern void blk_update_request(struct request *rq, int error,
|
extern void blk_update_request(struct request *rq, int error,
|
||||||
unsigned int nr_bytes);
|
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
|
* Access functions for manipulating queue properties
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user