Skip to content

Commit 9f180e3

Browse files
Ming Leiaxboe
Ming Lei
authored andcommitted
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 <[email protected]> Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Pavel Begunkov <[email protected]> Tested-by: Pavel Begunkov <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent c495a17 commit 9f180e3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

block/bio.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ static struct bio_slab *create_bio_slab(unsigned int size)
8989

9090
static inline unsigned int bs_bio_slab_size(struct bio_set *bs)
9191
{
92-
return bs->front_pad + sizeof(struct bio) +
93-
BIO_INLINE_VECS * sizeof(struct bio_vec);
92+
return bs->front_pad + sizeof(struct bio) + bs->back_pad;
9493
}
9594

9695
static struct kmem_cache *bio_find_or_create_slab(struct bio_set *bs)
@@ -1563,6 +1562,10 @@ int bioset_init(struct bio_set *bs,
15631562
int flags)
15641563
{
15651564
bs->front_pad = front_pad;
1565+
if (flags & BIOSET_NEED_BVECS)
1566+
bs->back_pad = BIO_INLINE_VECS * sizeof(struct bio_vec);
1567+
else
1568+
bs->back_pad = 0;
15661569

15671570
spin_lock_init(&bs->rescue_lock);
15681571
bio_list_init(&bs->rescue_list);

include/linux/bio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ struct bio_set {
703703
mempool_t bvec_integrity_pool;
704704
#endif
705705

706+
unsigned int back_pad;
706707
/*
707708
* Deadlock avoidance for stacking block drivers: see comments in
708709
* bio_alloc_bioset() for details

0 commit comments

Comments
 (0)