aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2019-08-01 18:50:41 -0400
committerJens Axboe <axboe@kernel.dk>2019-08-04 23:41:29 -0400
commitdad7758459bc6097115f5e783eda232f36b1ad99 (patch)
treecdf3e749fb4b8b0d9865f1c00c6139d64ee15e65 /block
parentaf2c68fe94e8c0a628519b60ba070c5cf6526a99 (diff)
block: Document the bio splitting functions
Since what the bio splitting functions do is nontrivial, document these functions. Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Cc: Christoph Hellwig <hch@infradead.org> Cc: Ming Lei <ming.lei@redhat.com> Cc: Hannes Reinecke <hare@suse.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/bio.c4
-rw-r--r--block/blk-merge.c43
2 files changed, 45 insertions, 2 deletions
diff --git a/block/bio.c b/block/bio.c
index 299a0e7651ec..0fff4eb9eb1e 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1842,8 +1842,8 @@ EXPORT_SYMBOL(bio_endio);
1842 * @bio, and updates @bio to represent the remaining sectors. 1842 * @bio, and updates @bio to represent the remaining sectors.
1843 * 1843 *
1844 * Unless this is a discard request the newly allocated bio will point 1844 * Unless this is a discard request the newly allocated bio will point
1845 * to @bio's bi_io_vec; it is the caller's responsibility to ensure that 1845 * to @bio's bi_io_vec. It is the caller's responsibility to ensure that
1846 * @bio is not freed before the split. 1846 * neither @bio nor @bs are freed before the split bio.
1847 */ 1847 */
1848struct bio *bio_split(struct bio *bio, int sectors, 1848struct bio *bio_split(struct bio *bio, int sectors,
1849 gfp_t gfp, struct bio_set *bs) 1849 gfp_t gfp, struct bio_set *bs)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 8344d94f13e0..51ed971709c3 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -195,6 +195,25 @@ static bool bvec_split_segs(const struct request_queue *q,
195 return !!len; 195 return !!len;
196} 196}
197 197
198/**
199 * blk_bio_segment_split - split a bio in two bios
200 * @q: [in] request queue pointer
201 * @bio: [in] bio to be split
202 * @bs: [in] bio set to allocate the clone from
203 * @segs: [out] number of segments in the bio with the first half of the sectors
204 *
205 * Clone @bio, update the bi_iter of the clone to represent the first sectors
206 * of @bio and update @bio->bi_iter to represent the remaining sectors. The
207 * following is guaranteed for the cloned bio:
208 * - That it has at most get_max_io_size(@q, @bio) sectors.
209 * - That it has at most queue_max_segments(@q) segments.
210 *
211 * Except for discard requests the cloned bio will point at the bi_io_vec of
212 * the original bio. It is the responsibility of the caller to ensure that the
213 * original bio is not freed before the cloned bio. The caller is also
214 * responsible for ensuring that @bs is only destroyed after processing of the
215 * split bio has finished.
216 */
198static struct bio *blk_bio_segment_split(struct request_queue *q, 217static struct bio *blk_bio_segment_split(struct request_queue *q,
199 struct bio *bio, 218 struct bio *bio,
200 struct bio_set *bs, 219 struct bio_set *bs,
@@ -251,6 +270,19 @@ split:
251 return bio_split(bio, sectors, GFP_NOIO, bs); 270 return bio_split(bio, sectors, GFP_NOIO, bs);
252} 271}
253 272
273/**
274 * __blk_queue_split - split a bio and submit the second half
275 * @q: [in] request queue pointer
276 * @bio: [in, out] bio to be split
277 * @nr_segs: [out] number of segments in the first bio
278 *
279 * Split a bio into two bios, chain the two bios, submit the second half and
280 * store a pointer to the first half in *@bio. If the second bio is still too
281 * big it will be split by a recursive call to this function. Since this
282 * function may allocate a new bio from @q->bio_split, it is the responsibility
283 * of the caller to ensure that @q is only released after processing of the
284 * split bio has finished.
285 */
254void __blk_queue_split(struct request_queue *q, struct bio **bio, 286void __blk_queue_split(struct request_queue *q, struct bio **bio,
255 unsigned int *nr_segs) 287 unsigned int *nr_segs)
256{ 288{
@@ -295,6 +327,17 @@ void __blk_queue_split(struct request_queue *q, struct bio **bio,
295 } 327 }
296} 328}
297 329
330/**
331 * blk_queue_split - split a bio and submit the second half
332 * @q: [in] request queue pointer
333 * @bio: [in, out] bio to be split
334 *
335 * Split a bio into two bios, chains the two bios, submit the second half and
336 * store a pointer to the first half in *@bio. Since this function may allocate
337 * a new bio from @q->bio_split, it is the responsibility of the caller to
338 * ensure that @q is only released after processing of the split bio has
339 * finished.
340 */
298void blk_queue_split(struct request_queue *q, struct bio **bio) 341void blk_queue_split(struct request_queue *q, struct bio **bio)
299{ 342{
300 unsigned int nr_segs; 343 unsigned int nr_segs;