summaryrefslogtreecommitdiff
path: root/block/bio.c
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2021-01-11 06:05:54 +0300
committerJens Axboe <axboe@kernel.dk>2021-01-25 07:22:45 +0300
commit9f180e315a93cde559ac1c9c4c5ce980aa681c1c (patch)
treea1469d03fead5c762d84d3b64f416fd34cd0aa33 /block/bio.c
parentc495a17679523c95f77f13697a71921dd5c224cd (diff)
downloadlinux-9f180e315a93cde559ac1c9c4c5ce980aa681c1c.tar.xz
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: Christoph Hellwig <hch@lst.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Pavel Begunkov <asml.silence@gmail.com> Tested-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bio.c')
-rw-r--r--block/bio.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/block/bio.c b/block/bio.c
index 87bf16460e0e..8ccda51dd831 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -89,8 +89,7 @@ fail_alloc_slab:
static inline unsigned int bs_bio_slab_size(struct bio_set *bs)
{
- return bs->front_pad + sizeof(struct bio) +
- BIO_INLINE_VECS * sizeof(struct bio_vec);
+ return bs->front_pad + sizeof(struct bio) + bs->back_pad;
}
static struct kmem_cache *bio_find_or_create_slab(struct bio_set *bs)
@@ -1563,6 +1562,10 @@ int bioset_init(struct bio_set *bs,
int flags)
{
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);
bio_list_init(&bs->rescue_list);