aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-core.c
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-05-11 04:56:09 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-05-11 05:06:48 -0400
commitb1f744937f1be3e6d3009382a755679133cf782d (patch)
tree0e90e43589ecfe28199030e8e396c0193199da7e /block/blk-core.c
parente6bb7a96c2c36f20c05ef648f15bd3c2b1834c78 (diff)
block: move completion related functions back to blk-core.c
Let's put the completion related functions back to block/blk-core.c where they have lived. We can also unexport blk_end_bidi_request() and __blk_end_bidi_request(), which nobody uses. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-core.c')
-rw-r--r--block/blk-core.c128
1 files changed, 122 insertions, 6 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 93691d2ac5a0..a2d97de1a12c 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2026,8 +2026,8 @@ static void blk_finish_request(struct request *req, int error)
2026 * %false - we are done with this request 2026 * %false - we are done with this request
2027 * %true - still buffers pending for this request 2027 * %true - still buffers pending for this request
2028 **/ 2028 **/
2029bool blk_end_bidi_request(struct request *rq, int error, 2029static bool blk_end_bidi_request(struct request *rq, int error,
2030 unsigned int nr_bytes, unsigned int bidi_bytes) 2030 unsigned int nr_bytes, unsigned int bidi_bytes)
2031{ 2031{
2032 struct request_queue *q = rq->q; 2032 struct request_queue *q = rq->q;
2033 unsigned long flags; 2033 unsigned long flags;
@@ -2041,7 +2041,6 @@ bool blk_end_bidi_request(struct request *rq, int error,
2041 2041
2042 return false; 2042 return false;
2043} 2043}
2044EXPORT_SYMBOL_GPL(blk_end_bidi_request);
2045 2044
2046/** 2045/**
2047 * __blk_end_bidi_request - Complete a bidi request with queue lock held 2046 * __blk_end_bidi_request - Complete a bidi request with queue lock held
@@ -2058,8 +2057,8 @@ EXPORT_SYMBOL_GPL(blk_end_bidi_request);
2058 * %false - we are done with this request 2057 * %false - we are done with this request
2059 * %true - still buffers pending for this request 2058 * %true - still buffers pending for this request
2060 **/ 2059 **/
2061bool __blk_end_bidi_request(struct request *rq, int error, 2060static bool __blk_end_bidi_request(struct request *rq, int error,
2062 unsigned int nr_bytes, unsigned int bidi_bytes) 2061 unsigned int nr_bytes, unsigned int bidi_bytes)
2063{ 2062{
2064 if (blk_update_bidi_request(rq, error, nr_bytes, bidi_bytes)) 2063 if (blk_update_bidi_request(rq, error, nr_bytes, bidi_bytes))
2065 return true; 2064 return true;
@@ -2068,7 +2067,124 @@ bool __blk_end_bidi_request(struct request *rq, int error,
2068 2067
2069 return false; 2068 return false;
2070} 2069}
2071EXPORT_SYMBOL_GPL(__blk_end_bidi_request); 2070
2071/**
2072 * blk_end_request - Helper function for drivers to complete the request.
2073 * @rq: the request being processed
2074 * @error: %0 for success, < %0 for error
2075 * @nr_bytes: number of bytes to complete
2076 *
2077 * Description:
2078 * Ends I/O on a number of bytes attached to @rq.
2079 * If @rq has leftover, sets it up for the next range of segments.
2080 *
2081 * Return:
2082 * %false - we are done with this request
2083 * %true - still buffers pending for this request
2084 **/
2085bool blk_end_request(struct request *rq, int error, unsigned int nr_bytes)
2086{
2087 return blk_end_bidi_request(rq, error, nr_bytes, 0);
2088}
2089EXPORT_SYMBOL_GPL(blk_end_request);
2090
2091/**
2092 * blk_end_request_all - Helper function for drives to finish the request.
2093 * @rq: the request to finish
2094 * @err: %0 for success, < %0 for error
2095 *
2096 * Description:
2097 * Completely finish @rq.
2098 */
2099void blk_end_request_all(struct request *rq, int error)
2100{
2101 bool pending;
2102 unsigned int bidi_bytes = 0;
2103
2104 if (unlikely(blk_bidi_rq(rq)))
2105 bidi_bytes = blk_rq_bytes(rq->next_rq);
2106
2107 pending = blk_end_bidi_request(rq, error, blk_rq_bytes(rq), bidi_bytes);
2108 BUG_ON(pending);
2109}
2110EXPORT_SYMBOL_GPL(blk_end_request_all);
2111
2112/**
2113 * blk_end_request_cur - Helper function to finish the current request chunk.
2114 * @rq: the request to finish the current chunk for
2115 * @err: %0 for success, < %0 for error
2116 *
2117 * Description:
2118 * Complete the current consecutively mapped chunk from @rq.
2119 *
2120 * Return:
2121 * %false - we are done with this request
2122 * %true - still buffers pending for this request
2123 */
2124bool blk_end_request_cur(struct request *rq, int error)
2125{
2126 return blk_end_request(rq, error, blk_rq_cur_bytes(rq));
2127}
2128EXPORT_SYMBOL_GPL(blk_end_request_cur);
2129
2130/**
2131 * __blk_end_request - Helper function for drivers to complete the request.
2132 * @rq: the request being processed
2133 * @error: %0 for success, < %0 for error
2134 * @nr_bytes: number of bytes to complete
2135 *
2136 * Description:
2137 * Must be called with queue lock held unlike blk_end_request().
2138 *
2139 * Return:
2140 * %false - we are done with this request
2141 * %true - still buffers pending for this request
2142 **/
2143bool __blk_end_request(struct request *rq, int error, unsigned int nr_bytes)
2144{
2145 return __blk_end_bidi_request(rq, error, nr_bytes, 0);
2146}
2147EXPORT_SYMBOL_GPL(__blk_end_request);
2148
2149/**
2150 * __blk_end_request_all - Helper function for drives to finish the request.
2151 * @rq: the request to finish
2152 * @err: %0 for success, < %0 for error
2153 *
2154 * Description:
2155 * Completely finish @rq. Must be called with queue lock held.
2156 */
2157void __blk_end_request_all(struct request *rq, int error)
2158{
2159 bool pending;
2160 unsigned int bidi_bytes = 0;
2161
2162 if (unlikely(blk_bidi_rq(rq)))
2163 bidi_bytes = blk_rq_bytes(rq->next_rq);
2164
2165 pending = __blk_end_bidi_request(rq, error, blk_rq_bytes(rq), bidi_bytes);
2166 BUG_ON(pending);
2167}
2168EXPORT_SYMBOL_GPL(__blk_end_request_all);
2169
2170/**
2171 * __blk_end_request_cur - Helper function to finish the current request chunk.
2172 * @rq: the request to finish the current chunk for
2173 * @err: %0 for success, < %0 for error
2174 *
2175 * Description:
2176 * Complete the current consecutively mapped chunk from @rq. Must
2177 * be called with queue lock held.
2178 *
2179 * Return:
2180 * %false - we are done with this request
2181 * %true - still buffers pending for this request
2182 */
2183bool __blk_end_request_cur(struct request *rq, int error)
2184{
2185 return __blk_end_request(rq, error, blk_rq_cur_bytes(rq));
2186}
2187EXPORT_SYMBOL_GPL(__blk_end_request_cur);
2072 2188
2073void blk_rq_bio_prep(struct request_queue *q, struct request *rq, 2189void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
2074 struct bio *bio) 2190 struct bio *bio)