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.h115
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
71static inline unsigned int bio_cur_bytes(struct bio *bio) 72static 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
87static 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
212extern struct bio_set *bioset_create(unsigned int, unsigned int); 222extern struct bio_set *bioset_create(unsigned int, unsigned int);
213extern void bioset_free(struct bio_set *); 223extern void bioset_free(struct bio_set *);
224extern mempool_t *biovec_create_pool(struct bio_set *bs, int pool_entries);
214 225
215extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); 226extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *);
216extern void bio_put(struct bio *); 227extern void bio_put(struct bio *);
@@ -245,6 +256,9 @@ extern void bio_endio(struct bio *, int);
245struct request_queue; 256struct request_queue;
246extern int bio_phys_segments(struct request_queue *, struct bio *); 257extern int bio_phys_segments(struct request_queue *, struct bio *);
247 258
259extern int submit_bio_wait(int rw, struct bio *bio);
260extern void bio_advance(struct bio *, unsigned);
261
248extern void bio_init(struct bio *); 262extern void bio_init(struct bio *);
249extern void bio_reset(struct bio *); 263extern 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
296extern void bio_copy_data(struct bio *dst, struct bio *src);
297extern int bio_alloc_pages(struct bio *bio, gfp_t gfp);
298
282extern struct bio *bio_copy_user(struct request_queue *, struct rq_map_data *, 299extern 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);
284extern struct bio *bio_copy_user_iov(struct request_queue *, 301extern 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);
287extern int bio_uncopy_user(struct bio *); 304extern int bio_uncopy_user(struct bio *);
288void zero_fill_bio(struct bio *bio); 305void zero_fill_bio(struct bio *bio);
289extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *); 306extern struct bio_vec *bvec_alloc(gfp_t, int, unsigned long *, mempool_t *);
290extern void bvec_free_bs(struct bio_set *, struct bio_vec *, unsigned int); 307extern void bvec_free(mempool_t *, struct bio_vec *, unsigned int);
291extern unsigned int bvec_nr_vecs(unsigned short idx); 308extern 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; }
298static inline void bio_disassociate_task(struct bio *bio) { } 315static 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
311struct 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
322struct 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
524struct 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
545struct 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)]))