summaryrefslogtreecommitdiffstats
path: root/include/linux/bio.h
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-11-23 21:21:01 -0500
committerKent Overstreet <kmo@daterainc.com>2013-11-24 01:33:57 -0500
commit20d0189b1012a37d2533a87fb451f7852f2418d1 (patch)
tree5ceaa6cfc0e1f1cec423c6c9f5de72d49f2d63a1 /include/linux/bio.h
parentee67891bf132612feb7b999ee1f3350b40867cb4 (diff)
block: Introduce new bio_split()
The new bio_split() can split arbitrary bios - it's not restricted to single page bios, like the old bio_split() (previously renamed to bio_pair_split()). It also has different semantics - it doesn't allocate a struct bio_pair, leaving it up to the caller to handle completions. Then convert the existing bio_pair_split() users to the new bio_split() - and also nvme, which was open coding bio splitting. (We have to take that BUG_ON() out of bio_integrity_trim() because this bio_split() needs to use it, and there's no reason it has to be used on bios marked as cloned; BIO_CLONED doesn't seem to have clearly documented semantics anyways.) Signed-off-by: Kent Overstreet <kmo@daterainc.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Matthew Wilcox <matthew.r.wilcox@intel.com> Cc: Keith Busch <keith.busch@intel.com> Cc: Vishal Verma <vishal.l.verma@intel.com> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Neil Brown <neilb@suse.de>
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r--include/linux/bio.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h
index aa67af0b31ac..19e31b2f5b2c 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -321,6 +321,28 @@ extern struct bio_pair *bio_pair_split(struct bio *bi, int first_sectors);
321extern void bio_pair_release(struct bio_pair *dbio); 321extern void bio_pair_release(struct bio_pair *dbio);
322extern void bio_trim(struct bio *bio, int offset, int size); 322extern void bio_trim(struct bio *bio, int offset, int size);
323 323
324extern struct bio *bio_split(struct bio *bio, int sectors,
325 gfp_t gfp, struct bio_set *bs);
326
327/**
328 * bio_next_split - get next @sectors from a bio, splitting if necessary
329 * @bio: bio to split
330 * @sectors: number of sectors to split from the front of @bio
331 * @gfp: gfp mask
332 * @bs: bio set to allocate from
333 *
334 * Returns a bio representing the next @sectors of @bio - if the bio is smaller
335 * than @sectors, returns the original bio unchanged.
336 */
337static inline struct bio *bio_next_split(struct bio *bio, int sectors,
338 gfp_t gfp, struct bio_set *bs)
339{
340 if (sectors >= bio_sectors(bio))
341 return bio;
342
343 return bio_split(bio, sectors, gfp, bs);
344}
345
324extern struct bio_set *bioset_create(unsigned int, unsigned int); 346extern struct bio_set *bioset_create(unsigned int, unsigned int);
325extern void bioset_free(struct bio_set *); 347extern void bioset_free(struct bio_set *);
326extern mempool_t *biovec_create_pool(struct bio_set *bs, int pool_entries); 348extern mempool_t *biovec_create_pool(struct bio_set *bs, int pool_entries);