Skip to content

Commit 51d654e

Browse files
martinkpetersenJens Axboe
authored andcommitted
block: Globalize bio_set and bio_vec_slab
Move struct bio_set and biovec_slab definitions to bio.h so they can be used outside of bio.c. Signed-off-by: Martin K. Petersen <[email protected]> Reviewed-by: Jeff Moyer <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent a144ff0 commit 51d654e

File tree

2 files changed

+31
-28
lines changed

2 files changed

+31
-28
lines changed

fs/bio.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,10 @@
2828
#include <linux/blktrace_api.h>
2929
#include <scsi/sg.h> /* for struct sg_iovec */
3030

31-
#define BIO_POOL_SIZE 2
32-
3331
static struct kmem_cache *bio_slab __read_mostly;
3432

35-
#define BIOVEC_NR_POOLS 6
36-
37-
/*
38-
* a small number of entries is fine, not going to be performance critical.
39-
* basically we just need to survive
40-
*/
41-
#define BIO_SPLIT_ENTRIES 2
4233
mempool_t *bio_split_pool __read_mostly;
4334

44-
struct biovec_slab {
45-
int nr_vecs;
46-
char *name;
47-
struct kmem_cache *slab;
48-
};
49-
5035
/*
5136
* if you change this list, also change bvec_alloc or things will
5237
* break badly! cannot be bigger than what you can fit into an
@@ -59,24 +44,13 @@ static struct biovec_slab bvec_slabs[BIOVEC_NR_POOLS] __read_mostly = {
5944
};
6045
#undef BV
6146

62-
/*
63-
* bio_set is used to allow other portions of the IO system to
64-
* allocate their own private memory pools for bio and iovec structures.
65-
* These memory pools in turn all allocate from the bio_slab
66-
* and the bvec_slabs[].
67-
*/
68-
struct bio_set {
69-
mempool_t *bio_pool;
70-
mempool_t *bvec_pools[BIOVEC_NR_POOLS];
71-
};
72-
7347
/*
7448
* fs_bio_set is the bio_set containing bio and iovec memory pools used by
7549
* IO code that does not need private memory pools.
7650
*/
77-
static struct bio_set *fs_bio_set;
51+
struct bio_set *fs_bio_set;
7852

79-
static inline struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
53+
struct bio_vec *bvec_alloc_bs(gfp_t gfp_mask, int nr, unsigned long *idx, struct bio_set *bs)
8054
{
8155
struct bio_vec *bvl;
8256

include/linux/bio.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,35 @@ extern struct bio *bio_copy_user_iov(struct request_queue *, struct sg_iovec *,
333333
int, int);
334334
extern int bio_uncopy_user(struct bio *);
335335
void zero_fill_bio(struct bio *bio);
336+
extern struct bio_vec *bvec_alloc_bs(gfp_t, int, unsigned long *, struct bio_set *);
337+
338+
/*
339+
* bio_set is used to allow other portions of the IO system to
340+
* allocate their own private memory pools for bio and iovec structures.
341+
* These memory pools in turn all allocate from the bio_slab
342+
* and the bvec_slabs[].
343+
*/
344+
#define BIO_POOL_SIZE 2
345+
#define BIOVEC_NR_POOLS 6
346+
347+
struct bio_set {
348+
mempool_t *bio_pool;
349+
mempool_t *bvec_pools[BIOVEC_NR_POOLS];
350+
};
351+
352+
struct biovec_slab {
353+
int nr_vecs;
354+
char *name;
355+
struct kmem_cache *slab;
356+
};
357+
358+
extern struct bio_set *fs_bio_set;
359+
360+
/*
361+
* a small number of entries is fine, not going to be performance critical.
362+
* basically we just need to survive
363+
*/
364+
#define BIO_SPLIT_ENTRIES 2
336365

337366
#ifdef CONFIG_HIGHMEM
338367
/*

0 commit comments

Comments
 (0)