aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/ll_rw_blk.c96
1 files changed, 96 insertions, 0 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 3d0422f48453..5c01911af47c 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -3791,6 +3791,102 @@ void end_request(struct request *req, int uptodate)
3791} 3791}
3792EXPORT_SYMBOL(end_request); 3792EXPORT_SYMBOL(end_request);
3793 3793
3794static void complete_request(struct request *rq, int error)
3795{
3796 /*
3797 * REMOVEME: This conversion is transitional and will be removed
3798 * when old end_that_request_* are unexported.
3799 */
3800 int uptodate = 1;
3801 if (error)
3802 uptodate = (error == -EIO) ? 0 : error;
3803
3804 if (blk_rq_tagged(rq))
3805 blk_queue_end_tag(rq->q, rq);
3806
3807 if (blk_queued_rq(rq))
3808 blkdev_dequeue_request(rq);
3809
3810 end_that_request_last(rq, uptodate);
3811}
3812
3813/**
3814 * blk_end_request - Helper function for drivers to complete the request.
3815 * @rq: the request being processed
3816 * @error: 0 for success, < 0 for error
3817 * @nr_bytes: number of bytes to complete
3818 *
3819 * Description:
3820 * Ends I/O on a number of bytes attached to @rq.
3821 * If @rq has leftover, sets it up for the next range of segments.
3822 *
3823 * Return:
3824 * 0 - we are done with this request
3825 * 1 - still buffers pending for this request
3826 **/
3827int blk_end_request(struct request *rq, int error, int nr_bytes)
3828{
3829 struct request_queue *q = rq->q;
3830 unsigned long flags = 0UL;
3831 /*
3832 * REMOVEME: This conversion is transitional and will be removed
3833 * when old end_that_request_* are unexported.
3834 */
3835 int uptodate = 1;
3836 if (error)
3837 uptodate = (error == -EIO) ? 0 : error;
3838
3839 if (blk_fs_request(rq) || blk_pc_request(rq)) {
3840 if (__end_that_request_first(rq, uptodate, nr_bytes))
3841 return 1;
3842 }
3843
3844 add_disk_randomness(rq->rq_disk);
3845
3846 spin_lock_irqsave(q->queue_lock, flags);
3847 complete_request(rq, error);
3848 spin_unlock_irqrestore(q->queue_lock, flags);
3849
3850 return 0;
3851}
3852EXPORT_SYMBOL_GPL(blk_end_request);
3853
3854/**
3855 * __blk_end_request - Helper function for drivers to complete the request.
3856 * @rq: the request being processed
3857 * @error: 0 for success, < 0 for error
3858 * @nr_bytes: number of bytes to complete
3859 *
3860 * Description:
3861 * Must be called with queue lock held unlike blk_end_request().
3862 *
3863 * Return:
3864 * 0 - we are done with this request
3865 * 1 - still buffers pending for this request
3866 **/
3867int __blk_end_request(struct request *rq, int error, int nr_bytes)
3868{
3869 /*
3870 * REMOVEME: This conversion is transitional and will be removed
3871 * when old end_that_request_* are unexported.
3872 */
3873 int uptodate = 1;
3874 if (error)
3875 uptodate = (error == -EIO) ? 0 : error;
3876
3877 if (blk_fs_request(rq) || blk_pc_request(rq)) {
3878 if (__end_that_request_first(rq, uptodate, nr_bytes))
3879 return 1;
3880 }
3881
3882 add_disk_randomness(rq->rq_disk);
3883
3884 complete_request(rq, error);
3885
3886 return 0;
3887}
3888EXPORT_SYMBOL_GPL(__blk_end_request);
3889
3794static void blk_rq_bio_prep(struct request_queue *q, struct request *rq, 3890static void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
3795 struct bio *bio) 3891 struct bio *bio)
3796{ 3892{