block: replace end_request() with [__]blk_end_request_cur()

end_request() has been kept around for backward compatibility;
however, it's about time for it to go away.

* There aren't too many users left.

* Its use of @updtodate is pretty confusing.

* In some cases, newer code ends up using mixture of end_request() and
  [__]blk_end_request[_all](), which is way too confusing.

So, add [__]blk_end_request_cur() and replace end_request() with it.
Most conversions are straightforward.  Noteworthy ones are...

* paride/pcd: next_request() updated to take 0/-errno instead of 1/0.

* paride/pf: pf_end_request() and next_request() updated to take
  0/-errno instead of 1/0.

* xd: xd_readwrite() updated to return 0/-errno instead of 1/0.

* mtd/mtd_blkdevs: blktrans_discard_request() updated to return
  0/-errno instead of 1/0.  Unnecessary local variable res
  initialization removed from mtd_blktrans_thread().

[ Impact: cleanup ]

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Joerg Dorchain <joerg@dorchain.net>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Laurent Vivier <Laurent@lvivier.info>
Cc: Tim Waugh <tim@cyberelk.net>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Markus Lidel <Markus.Lidel@shadowconnect.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Pete Zaitcev <zaitcev@redhat.com>
Cc: unsik Kim <donari75@gmail.com>
This commit is contained in:
Tejun Heo 2009-04-23 11:05:19 +09:00 committed by Jens Axboe
parent 40cbbb781d
commit f06d9a2b52
19 changed files with 128 additions and 126 deletions

View file

@ -845,9 +845,8 @@ extern unsigned int blk_rq_cur_bytes(struct request *rq);
* blk_update_request() completes given number of bytes and updates
* the request without completing it.
*
* blk_end_request() and friends. __blk_end_request() and
* end_request() must be called with the request queue spinlock
* acquired.
* blk_end_request() and friends. __blk_end_request() must be called
* with the request queue spinlock acquired.
*
* Several drivers define their own end_request and call
* blk_end_request() for parts of the original function.
@ -898,6 +897,19 @@ static inline void blk_end_request_all(struct request *rq, int error)
BUG_ON(pending);
}
/**
* blk_end_request_cur - Helper function to finish the current request chunk.
* @rq: the request to finish the current chunk for
* @err: %0 for success, < %0 for error
*
* Description:
* Complete the current consecutively mapped chunk from @rq.
*/
static inline void blk_end_request_cur(struct request *rq, int error)
{
blk_end_request(rq, error, rq->hard_cur_sectors << 9);
}
/**
* __blk_end_request - Helper function for drivers to complete the request.
* @rq: the request being processed
@ -934,29 +946,17 @@ static inline void __blk_end_request_all(struct request *rq, int error)
}
/**
* end_request - end I/O on the current segment of the request
* @rq: the request being processed
* @uptodate: error value or %0/%1 uptodate flag
* __blk_end_request_cur - Helper function to finish the current request chunk.
* @rq: the request to finish the current chunk for
* @err: %0 for success, < %0 for error
*
* 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.
**/
static inline void end_request(struct request *rq, int uptodate)
* Complete the current consecutively mapped chunk from @rq. Must
* be called with queue lock held.
*/
static inline void __blk_end_request_cur(struct request *rq, int error)
{
int error = 0;
if (uptodate <= 0)
error = uptodate ? uptodate : -EIO;
__blk_end_bidi_request(rq, error, rq->hard_cur_sectors << 9, 0);
__blk_end_request(rq, error, rq->hard_cur_sectors << 9);
}
extern void blk_complete_request(struct request *);