diff options
Diffstat (limited to 'include/linux/bio.h')
| -rw-r--r-- | include/linux/bio.h | 115 |
1 files changed, 71 insertions, 44 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index 820e7aaad4fd..ef24466d8f82 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
| @@ -67,6 +67,7 @@ | |||
| 67 | #define bio_offset(bio) bio_iovec((bio))->bv_offset | 67 | #define bio_offset(bio) bio_iovec((bio))->bv_offset |
| 68 | #define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx) | 68 | #define bio_segments(bio) ((bio)->bi_vcnt - (bio)->bi_idx) |
| 69 | #define bio_sectors(bio) ((bio)->bi_size >> 9) | 69 | #define bio_sectors(bio) ((bio)->bi_size >> 9) |
| 70 | #define bio_end_sector(bio) ((bio)->bi_sector + bio_sectors((bio))) | ||
| 70 | 71 | ||
| 71 | static inline unsigned int bio_cur_bytes(struct bio *bio) | 72 | static inline unsigned int bio_cur_bytes(struct bio *bio) |
| 72 | { | 73 | { |
| @@ -84,11 +85,6 @@ static inline void *bio_data(struct bio *bio) | |||
| 84 | return NULL; | 85 | return NULL; |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 87 | static inline int bio_has_allocated_vec(struct bio *bio) | ||
| 88 | { | ||
| 89 | return bio->bi_io_vec && bio->bi_io_vec != bio->bi_inline_vecs; | ||
| 90 | } | ||
| 91 | |||
| 92 | /* | 88 | /* |
| 93 | * will die | 89 | * will die |
| 94 | */ | 90 | */ |
| @@ -136,16 +132,27 @@ static inline int bio_has_allocated_vec(struct bio *bio) | |||
| 136 | #define bio_io_error(bio) bio_endio((bio), -EIO) | 132 | #define bio_io_error(bio) bio_endio((bio), -EIO) |
| 137 | 133 | ||
| 138 | /* | 134 | /* |
| 139 | * drivers should not use the __ version unless they _really_ want to | 135 | * drivers should not use the __ version unless they _really_ know what |
| 140 | * run through the entire bio and not just pending pieces | 136 | * they're doing |
| 141 | */ | 137 | */ |
| 142 | #define __bio_for_each_segment(bvl, bio, i, start_idx) \ | 138 | #define __bio_for_each_segment(bvl, bio, i, start_idx) \ |
| 143 | for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ | 139 | for (bvl = bio_iovec_idx((bio), (start_idx)), i = (start_idx); \ |
| 144 | i < (bio)->bi_vcnt; \ | 140 | i < (bio)->bi_vcnt; \ |
| 145 | bvl++, i++) | 141 | bvl++, i++) |
| 146 | 142 | ||
| 143 | /* | ||
| 144 | * drivers should _never_ use the all version - the bio may have been split | ||
| 145 | * before it got to the driver and the driver won't own all of it | ||
| 146 | */ | ||
| 147 | #define bio_for_each_segment_all(bvl, bio, i) \ | ||
| 148 | for (i = 0; \ | ||
| 149 | bvl = bio_iovec_idx((bio), (i)), i < (bio)->bi_vcnt; \ | ||
| 150 | i++) | ||
| 151 | |||
| 147 | #define bio_for_each_segment(bvl, bio, i) \ | 152 | #define bio_for_each_segment(bvl, bio, i) \ |
| 148 | __bio_for_each_segment(bvl, bio, i, (bio)->bi_idx) | 153 | for (i = (bio)->bi_idx; \ |
| 154 | bvl = bio_iovec_idx((bio), (i)), i < (bio)->bi_vcnt; \ | ||
| 155 | i++) | ||
| 149 | 156 | ||
| 150 | /* | 157 | /* |
| 151 | * get a reference to a bio, so it won't disappear. the intended use is | 158 | * get a reference to a bio, so it won't disappear. the intended use is |
| @@ -180,9 +187,12 @@ struct bio_integrity_payload { | |||
| 180 | unsigned short bip_slab; /* slab the bip came from */ | 187 | unsigned short bip_slab; /* slab the bip came from */ |
| 181 | unsigned short bip_vcnt; /* # of integrity bio_vecs */ | 188 | unsigned short bip_vcnt; /* # of integrity bio_vecs */ |
| 182 | unsigned short bip_idx; /* current bip_vec index */ | 189 | unsigned short bip_idx; /* current bip_vec index */ |
| 190 | unsigned bip_owns_buf:1; /* should free bip_buf */ | ||
| 183 | 191 | ||
| 184 | struct work_struct bip_work; /* I/O completion */ | 192 | struct work_struct bip_work; /* I/O completion */ |
| 185 | struct bio_vec bip_vec[0]; /* embedded bvec array */ | 193 | |
| 194 | struct bio_vec *bip_vec; | ||
| 195 | struct bio_vec bip_inline_vecs[0];/* embedded bvec array */ | ||
| 186 | }; | 196 | }; |
| 187 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ | 197 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ |
| 188 | 198 | ||
| @@ -211,6 +221,7 @@ extern void bio_pair_release(struct bio_pair *dbio); | |||
| 211 | 221 | ||
| 212 | extern struct bio_set *bioset_create(unsigned int, unsigned int); | 222 | extern struct bio_set *bioset_create(unsigned int, unsigned int); |
| 213 | extern void bioset_free(struct bio_set *); | 223 | extern void bioset_free(struct bio_set *); |
| 224 | extern mempool_t *biovec_create_pool(struct bio_set *bs, int pool_entries); | ||
| 214 | 225 | ||
| 215 | extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); | 226 | extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); |
| 216 | extern void bio_put(struct bio *); | 227 | extern void bio_put(struct bio *); |
| @@ -245,6 +256,9 @@ extern void bio_endio(struct bio *, int); | |||
| 245 | struct request_queue; | 256 | struct request_queue; |
| 246 | extern int bio_phys_segments(struct request_queue *, struct bio *); | 257 | extern int bio_phys_segments(struct request_queue *, struct bio *); |
| 247 | 258 | ||
| 259 | extern int submit_bio_wait(int rw, struct bio *bio); | ||
| 260 | extern void bio_advance(struct bio *, unsigned); | ||
| 261 | |||
| 248 | extern void bio_init(struct bio *); | 262 | extern void bio_init(struct bio *); |
| 249 | extern void bio_reset(struct bio *); | 263 | extern void bio_reset(struct bio *); |
| 250 | 264 | ||
| @@ -279,6 +293,9 @@ static inline void bio_flush_dcache_pages(struct bio *bi) | |||
| 279 | } | 293 | } |
| 280 | #endif | 294 | #endif |
| 281 | 295 | ||
| 296 | extern void bio_copy_data(struct bio *dst, struct bio *src); | ||
| 297 | extern int bio_alloc_pages(struct bio *bio, gfp_t gfp); | ||
| 298 | |||
| 282 | extern struct bio *bio_copy_user(struct request_queue *, struct rq_map_data *, | 299 | extern struct bio *bio_copy_user(struct request_queue *, struct rq_map_data *, |
| 283 | unsigned long, unsigned int, int, gfp_t); | 300 | unsigned long, unsigned int, int, gfp_t); |
| 284 | extern struct bio *bio_copy_user_iov(struct request_queue *, | 301 | extern struct bio *bio_copy_user_iov(struct request_queue *, |
| @@ -286,8 +303,8 @@ extern struct bio *bio_copy_user_iov(struct request_queue *, | |||
| 286 | int, int, gfp_t); | 303 | int, int, gfp_t); |
| 287 | extern int bio_uncopy_user(struct bio *); | 304 | extern int bio_uncopy_user(struct bio *); |
| 288 | void zero_fill_bio(struct bio *bio); | 305 | void zero_fill_bio(struct bio *bio); |
| 289 | extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *); | 306 | extern struct bio_vec *bvec_alloc(gfp_t, int, unsigned long *, mempool_t *); |
| 290 | extern void bvec_free_bs(struct bio_set *, struct bio_vec *, unsigned int); | 307 | extern void bvec_free(mempool_t *, struct bio_vec *, unsigned int); |
| 291 | extern unsigned int bvec_nr_vecs(unsigned short idx); | 308 | extern unsigned int bvec_nr_vecs(unsigned short idx); |
| 292 | 309 | ||
| 293 | #ifdef CONFIG_BLK_CGROUP | 310 | #ifdef CONFIG_BLK_CGROUP |
| @@ -298,39 +315,6 @@ static inline int bio_associate_current(struct bio *bio) { return -ENOENT; } | |||
| 298 | static inline void bio_disassociate_task(struct bio *bio) { } | 315 | static inline void bio_disassociate_task(struct bio *bio) { } |
| 299 | #endif /* CONFIG_BLK_CGROUP */ | 316 | #endif /* CONFIG_BLK_CGROUP */ |
| 300 | 317 | ||
| 301 | /* | ||
| 302 | * bio_set is used to allow other portions of the IO system to | ||
| 303 | * allocate their own private memory pools for bio and iovec structures. | ||
| 304 | * These memory pools in turn all allocate from the bio_slab | ||
| 305 | * and the bvec_slabs[]. | ||
| 306 | */ | ||
| 307 | #define BIO_POOL_SIZE 2 | ||
| 308 | #define BIOVEC_NR_POOLS 6 | ||
| 309 | #define BIOVEC_MAX_IDX (BIOVEC_NR_POOLS - 1) | ||
| 310 | |||
| 311 | struct bio_set { | ||
| 312 | struct kmem_cache *bio_slab; | ||
| 313 | unsigned int front_pad; | ||
| 314 | |||
| 315 | mempool_t *bio_pool; | ||
| 316 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | ||
| 317 | mempool_t *bio_integrity_pool; | ||
| 318 | #endif | ||
| 319 | mempool_t *bvec_pool; | ||
| 320 | }; | ||
| 321 | |||
| 322 | struct biovec_slab { | ||
| 323 | int nr_vecs; | ||
| 324 | char *name; | ||
| 325 | struct kmem_cache *slab; | ||
| 326 | }; | ||
| 327 | |||
| 328 | /* | ||
| 329 | * a small number of entries is fine, not going to be performance critical. | ||
| 330 | * basically we just need to survive | ||
| 331 | */ | ||
| 332 | #define BIO_SPLIT_ENTRIES 2 | ||
| 333 | |||
| 334 | #ifdef CONFIG_HIGHMEM | 318 | #ifdef CONFIG_HIGHMEM |
| 335 | /* | 319 | /* |
| 336 | * remember never ever reenable interrupts between a bvec_kmap_irq and | 320 | * remember never ever reenable interrupts between a bvec_kmap_irq and |
| @@ -527,6 +511,49 @@ static inline struct bio *bio_list_get(struct bio_list *bl) | |||
| 527 | return bio; | 511 | return bio; |
| 528 | } | 512 | } |
| 529 | 513 | ||
| 514 | /* | ||
| 515 | * bio_set is used to allow other portions of the IO system to | ||
| 516 | * allocate their own private memory pools for bio and iovec structures. | ||
| 517 | * These memory pools in turn all allocate from the bio_slab | ||
| 518 | * and the bvec_slabs[]. | ||
| 519 | */ | ||
| 520 | #define BIO_POOL_SIZE 2 | ||
| 521 | #define BIOVEC_NR_POOLS 6 | ||
| 522 | #define BIOVEC_MAX_IDX (BIOVEC_NR_POOLS - 1) | ||
| 523 | |||
| 524 | struct bio_set { | ||
| 525 | struct kmem_cache *bio_slab; | ||
| 526 | unsigned int front_pad; | ||
| 527 | |||
| 528 | mempool_t *bio_pool; | ||
| 529 | mempool_t *bvec_pool; | ||
| 530 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | ||
| 531 | mempool_t *bio_integrity_pool; | ||
| 532 | mempool_t *bvec_integrity_pool; | ||
| 533 | #endif | ||
| 534 | |||
| 535 | /* | ||
| 536 | * Deadlock avoidance for stacking block drivers: see comments in | ||
| 537 | * bio_alloc_bioset() for details | ||
| 538 | */ | ||
| 539 | spinlock_t rescue_lock; | ||
| 540 | struct bio_list rescue_list; | ||
| 541 | struct work_struct rescue_work; | ||
| 542 | struct workqueue_struct *rescue_workqueue; | ||
| 543 | }; | ||
| 544 | |||
| 545 | struct biovec_slab { | ||
| 546 | int nr_vecs; | ||
| 547 | char *name; | ||
| 548 | struct kmem_cache *slab; | ||
| 549 | }; | ||
| 550 | |||
| 551 | /* | ||
| 552 | * a small number of entries is fine, not going to be performance critical. | ||
| 553 | * basically we just need to survive | ||
| 554 | */ | ||
| 555 | #define BIO_SPLIT_ENTRIES 2 | ||
| 556 | |||
| 530 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | 557 | #if defined(CONFIG_BLK_DEV_INTEGRITY) |
| 531 | 558 | ||
| 532 | #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) | 559 | #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) |
