Commit 9f180e31 authored by Ming Lei's avatar Ming Lei Committed by Jens Axboe

block: don't allocate inline bvecs if this bioset needn't bvecs

The inline bvecs won't be used if user needn't bvecs by not passing
BIOSET_NEED_BVECS, so don't allocate bvecs in this situation.
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Reviewed-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Tested-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c495a176
...@@ -89,8 +89,7 @@ static struct bio_slab *create_bio_slab(unsigned int size) ...@@ -89,8 +89,7 @@ static struct bio_slab *create_bio_slab(unsigned int size)
static inline unsigned int bs_bio_slab_size(struct bio_set *bs) static inline unsigned int bs_bio_slab_size(struct bio_set *bs)
{ {
return bs->front_pad + sizeof(struct bio) + return bs->front_pad + sizeof(struct bio) + bs->back_pad;
BIO_INLINE_VECS * sizeof(struct bio_vec);
} }
static struct kmem_cache *bio_find_or_create_slab(struct bio_set *bs) static struct kmem_cache *bio_find_or_create_slab(struct bio_set *bs)
...@@ -1563,6 +1562,10 @@ int bioset_init(struct bio_set *bs, ...@@ -1563,6 +1562,10 @@ int bioset_init(struct bio_set *bs,
int flags) int flags)
{ {
bs->front_pad = front_pad; bs->front_pad = front_pad;
if (flags & BIOSET_NEED_BVECS)
bs->back_pad = BIO_INLINE_VECS * sizeof(struct bio_vec);
else
bs->back_pad = 0;
spin_lock_init(&bs->rescue_lock); spin_lock_init(&bs->rescue_lock);
bio_list_init(&bs->rescue_list); bio_list_init(&bs->rescue_list);
......
...@@ -703,6 +703,7 @@ struct bio_set { ...@@ -703,6 +703,7 @@ struct bio_set {
mempool_t bvec_integrity_pool; mempool_t bvec_integrity_pool;
#endif #endif
unsigned int back_pad;
/* /*
* Deadlock avoidance for stacking block drivers: see comments in * Deadlock avoidance for stacking block drivers: see comments in
* bio_alloc_bioset() for details * bio_alloc_bioset() for details
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment