diff options
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r-- | include/linux/bio.h | 94 |
1 files changed, 90 insertions, 4 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h index 49dfb3cb7460..6bfc3e8d9d89 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
@@ -64,6 +64,7 @@ struct bio_vec { | |||
64 | 64 | ||
65 | struct bio_set; | 65 | struct bio_set; |
66 | struct bio; | 66 | struct bio; |
67 | struct bio_integrity_payload; | ||
67 | typedef void (bio_end_io_t) (struct bio *, int); | 68 | typedef void (bio_end_io_t) (struct bio *, int); |
68 | typedef void (bio_destructor_t) (struct bio *); | 69 | typedef void (bio_destructor_t) (struct bio *); |
69 | 70 | ||
@@ -112,6 +113,9 @@ struct bio { | |||
112 | atomic_t bi_cnt; /* pin count */ | 113 | atomic_t bi_cnt; /* pin count */ |
113 | 114 | ||
114 | void *bi_private; | 115 | void *bi_private; |
116 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | ||
117 | struct bio_integrity_payload *bi_integrity; /* data integrity */ | ||
118 | #endif | ||
115 | 119 | ||
116 | bio_destructor_t *bi_destructor; /* destructor */ | 120 | bio_destructor_t *bi_destructor; /* destructor */ |
117 | }; | 121 | }; |
@@ -271,6 +275,29 @@ static inline void *bio_data(struct bio *bio) | |||
271 | */ | 275 | */ |
272 | #define bio_get(bio) atomic_inc(&(bio)->bi_cnt) | 276 | #define bio_get(bio) atomic_inc(&(bio)->bi_cnt) |
273 | 277 | ||
278 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | ||
279 | /* | ||
280 | * bio integrity payload | ||
281 | */ | ||
282 | struct bio_integrity_payload { | ||
283 | struct bio *bip_bio; /* parent bio */ | ||
284 | struct bio_vec *bip_vec; /* integrity data vector */ | ||
285 | |||
286 | sector_t bip_sector; /* virtual start sector */ | ||
287 | |||
288 | void *bip_buf; /* generated integrity data */ | ||
289 | bio_end_io_t *bip_end_io; /* saved I/O completion fn */ | ||
290 | |||
291 | int bip_error; /* saved I/O error */ | ||
292 | unsigned int bip_size; | ||
293 | |||
294 | unsigned short bip_pool; /* pool the ivec came from */ | ||
295 | unsigned short bip_vcnt; /* # of integrity bio_vecs */ | ||
296 | unsigned short bip_idx; /* current bip_vec index */ | ||
297 | |||
298 | struct work_struct bip_work; /* I/O completion */ | ||
299 | }; | ||
300 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ | ||
274 | 301 | ||
275 | /* | 302 | /* |
276 | * A bio_pair is used when we need to split a bio. | 303 | * A bio_pair is used when we need to split a bio. |
@@ -283,10 +310,14 @@ static inline void *bio_data(struct bio *bio) | |||
283 | * in bio2.bi_private | 310 | * in bio2.bi_private |
284 | */ | 311 | */ |
285 | struct bio_pair { | 312 | struct bio_pair { |
286 | struct bio bio1, bio2; | 313 | struct bio bio1, bio2; |
287 | struct bio_vec bv1, bv2; | 314 | struct bio_vec bv1, bv2; |
288 | atomic_t cnt; | 315 | #if defined(CONFIG_BLK_DEV_INTEGRITY) |
289 | int error; | 316 | struct bio_integrity_payload bip1, bip2; |
317 | struct bio_vec iv1, iv2; | ||
318 | #endif | ||
319 | atomic_t cnt; | ||
320 | int error; | ||
290 | }; | 321 | }; |
291 | extern struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, | 322 | extern struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, |
292 | int first_sectors); | 323 | int first_sectors); |
@@ -334,6 +365,7 @@ extern struct bio *bio_copy_user_iov(struct request_queue *, struct sg_iovec *, | |||
334 | extern int bio_uncopy_user(struct bio *); | 365 | extern int bio_uncopy_user(struct bio *); |
335 | void zero_fill_bio(struct bio *bio); | 366 | void zero_fill_bio(struct bio *bio); |
336 | extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *); | 367 | extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *); |
368 | extern unsigned int bvec_nr_vecs(unsigned short idx); | ||
337 | 369 | ||
338 | /* | 370 | /* |
339 | * bio_set is used to allow other portions of the IO system to | 371 | * bio_set is used to allow other portions of the IO system to |
@@ -346,6 +378,9 @@ extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set | |||
346 | 378 | ||
347 | struct bio_set { | 379 | struct bio_set { |
348 | mempool_t *bio_pool; | 380 | mempool_t *bio_pool; |
381 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | ||
382 | mempool_t *bio_integrity_pool; | ||
383 | #endif | ||
349 | mempool_t *bvec_pools[BIOVEC_NR_POOLS]; | 384 | mempool_t *bvec_pools[BIOVEC_NR_POOLS]; |
350 | }; | 385 | }; |
351 | 386 | ||
@@ -410,5 +445,56 @@ static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx, | |||
410 | __bio_kmap_irq((bio), (bio)->bi_idx, (flags)) | 445 | __bio_kmap_irq((bio), (bio)->bi_idx, (flags)) |
411 | #define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags) | 446 | #define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags) |
412 | 447 | ||
448 | #if defined(CONFIG_BLK_DEV_INTEGRITY) | ||
449 | |||
450 | #define bip_vec_idx(bip, idx) (&(bip->bip_vec[(idx)])) | ||
451 | #define bip_vec(bip) bip_vec_idx(bip, 0) | ||
452 | |||
453 | #define __bip_for_each_vec(bvl, bip, i, start_idx) \ | ||
454 | for (bvl = bip_vec_idx((bip), (start_idx)), i = (start_idx); \ | ||
455 | i < (bip)->bip_vcnt; \ | ||
456 | bvl++, i++) | ||
457 | |||
458 | #define bip_for_each_vec(bvl, bip, i) \ | ||
459 | __bip_for_each_vec(bvl, bip, i, (bip)->bip_idx) | ||
460 | |||
461 | #define bio_integrity(bio) ((bio)->bi_integrity ? 1 : 0) | ||
462 | |||
463 | extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *); | ||
464 | extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); | ||
465 | extern void bio_integrity_free(struct bio *, struct bio_set *); | ||
466 | extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int); | ||
467 | extern int bio_integrity_enabled(struct bio *bio); | ||
468 | extern int bio_integrity_set_tag(struct bio *, void *, unsigned int); | ||
469 | extern int bio_integrity_get_tag(struct bio *, void *, unsigned int); | ||
470 | extern int bio_integrity_prep(struct bio *); | ||
471 | extern void bio_integrity_endio(struct bio *, int); | ||
472 | extern void bio_integrity_advance(struct bio *, unsigned int); | ||
473 | extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int); | ||
474 | extern void bio_integrity_split(struct bio *, struct bio_pair *, int); | ||
475 | extern int bio_integrity_clone(struct bio *, struct bio *, struct bio_set *); | ||
476 | extern int bioset_integrity_create(struct bio_set *, int); | ||
477 | extern void bioset_integrity_free(struct bio_set *); | ||
478 | extern void bio_integrity_init_slab(void); | ||
479 | |||
480 | #else /* CONFIG_BLK_DEV_INTEGRITY */ | ||
481 | |||
482 | #define bio_integrity(a) (0) | ||
483 | #define bioset_integrity_create(a, b) (0) | ||
484 | #define bio_integrity_prep(a) (0) | ||
485 | #define bio_integrity_enabled(a) (0) | ||
486 | #define bio_integrity_clone(a, b, c) (0) | ||
487 | #define bioset_integrity_free(a) do { } while (0) | ||
488 | #define bio_integrity_free(a, b) do { } while (0) | ||
489 | #define bio_integrity_endio(a, b) do { } while (0) | ||
490 | #define bio_integrity_advance(a, b) do { } while (0) | ||
491 | #define bio_integrity_trim(a, b, c) do { } while (0) | ||
492 | #define bio_integrity_split(a, b, c) do { } while (0) | ||
493 | #define bio_integrity_set_tag(a, b, c) do { } while (0) | ||
494 | #define bio_integrity_get_tag(a, b, c) do { } while (0) | ||
495 | #define bio_integrity_init_slab(a) do { } while (0) | ||
496 | |||
497 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ | ||
498 | |||
413 | #endif /* CONFIG_BLOCK */ | 499 | #endif /* CONFIG_BLOCK */ |
414 | #endif /* __LINUX_BIO_H */ | 500 | #endif /* __LINUX_BIO_H */ |