aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bio.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r--include/linux/bio.h130
1 files changed, 126 insertions, 4 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 61c15eaf3fb3..0933a14e6414 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -64,6 +64,7 @@ struct bio_vec {
64 64
65struct bio_set; 65struct bio_set;
66struct bio; 66struct bio;
67struct bio_integrity_payload;
67typedef void (bio_end_io_t) (struct bio *, int); 68typedef void (bio_end_io_t) (struct bio *, int);
68typedef void (bio_destructor_t) (struct bio *); 69typedef 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 */
282struct 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 */
285struct bio_pair { 312struct 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};
291extern struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, 322extern struct bio_pair *bio_split(struct bio *bi, mempool_t *pool,
292 int first_sectors); 323 int first_sectors);
@@ -333,6 +364,39 @@ extern struct bio *bio_copy_user_iov(struct request_queue *, struct sg_iovec *,
333 int, int); 364 int, int);
334extern int bio_uncopy_user(struct bio *); 365extern int bio_uncopy_user(struct bio *);
335void zero_fill_bio(struct bio *bio); 366void zero_fill_bio(struct bio *bio);
367extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *);
368extern unsigned int bvec_nr_vecs(unsigned short idx);
369
370/*
371 * bio_set is used to allow other portions of the IO system to
372 * allocate their own private memory pools for bio and iovec structures.
373 * These memory pools in turn all allocate from the bio_slab
374 * and the bvec_slabs[].
375 */
376#define BIO_POOL_SIZE 2
377#define BIOVEC_NR_POOLS 6
378
379struct bio_set {
380 mempool_t *bio_pool;
381#if defined(CONFIG_BLK_DEV_INTEGRITY)
382 mempool_t *bio_integrity_pool;
383#endif
384 mempool_t *bvec_pools[BIOVEC_NR_POOLS];
385};
386
387struct biovec_slab {
388 int nr_vecs;
389 char *name;
390 struct kmem_cache *slab;
391};
392
393extern struct bio_set *fs_bio_set;
394
395/*
396 * a small number of entries is fine, not going to be performance critical.
397 * basically we just need to survive
398 */
399#define BIO_SPLIT_ENTRIES 2
336 400
337#ifdef CONFIG_HIGHMEM 401#ifdef CONFIG_HIGHMEM
338/* 402/*
@@ -381,5 +445,63 @@ static inline char *__bio_kmap_irq(struct bio *bio, unsigned short idx,
381 __bio_kmap_irq((bio), (bio)->bi_idx, (flags)) 445 __bio_kmap_irq((bio), (bio)->bi_idx, (flags))
382#define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags) 446#define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags)
383 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
461static inline int bio_integrity(struct bio *bio)
462{
463#if defined(CONFIG_BLK_DEV_INTEGRITY)
464 return bio->bi_integrity != NULL;
465#else
466 return 0;
467#endif
468}
469
470extern struct bio_integrity_payload *bio_integrity_alloc_bioset(struct bio *, gfp_t, unsigned int, struct bio_set *);
471extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int);
472extern void bio_integrity_free(struct bio *, struct bio_set *);
473extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);
474extern int bio_integrity_enabled(struct bio *bio);
475extern int bio_integrity_set_tag(struct bio *, void *, unsigned int);
476extern int bio_integrity_get_tag(struct bio *, void *, unsigned int);
477extern int bio_integrity_prep(struct bio *);
478extern void bio_integrity_endio(struct bio *, int);
479extern void bio_integrity_advance(struct bio *, unsigned int);
480extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int);
481extern void bio_integrity_split(struct bio *, struct bio_pair *, int);
482extern int bio_integrity_clone(struct bio *, struct bio *, struct bio_set *);
483extern int bioset_integrity_create(struct bio_set *, int);
484extern void bioset_integrity_free(struct bio_set *);
485extern void bio_integrity_init_slab(void);
486
487#else /* CONFIG_BLK_DEV_INTEGRITY */
488
489#define bio_integrity(a) (0)
490#define bioset_integrity_create(a, b) (0)
491#define bio_integrity_prep(a) (0)
492#define bio_integrity_enabled(a) (0)
493#define bio_integrity_clone(a, b, c) (0)
494#define bioset_integrity_free(a) do { } while (0)
495#define bio_integrity_free(a, b) do { } while (0)
496#define bio_integrity_endio(a, b) do { } while (0)
497#define bio_integrity_advance(a, b) do { } while (0)
498#define bio_integrity_trim(a, b, c) do { } while (0)
499#define bio_integrity_split(a, b, c) do { } while (0)
500#define bio_integrity_set_tag(a, b, c) do { } while (0)
501#define bio_integrity_get_tag(a, b, c) do { } while (0)
502#define bio_integrity_init_slab(a) do { } while (0)
503
504#endif /* CONFIG_BLK_DEV_INTEGRITY */
505
384#endif /* CONFIG_BLOCK */ 506#endif /* CONFIG_BLOCK */
385#endif /* __LINUX_BIO_H */ 507#endif /* __LINUX_BIO_H */