Skip to content

Commit

Permalink
block: don't allocate inline bvecs if this bioset needn't bvecs
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Ming Lei authored and axboe committed Jan 25, 2021
1 parent c495a17 commit 9f180e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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)
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions include/linux/bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ struct bio_set {
mempool_t bvec_integrity_pool;
#endif

unsigned int back_pad;
/*
* Deadlock avoidance for stacking block drivers: see comments in
* bio_alloc_bioset() for details
Expand Down

0 comments on commit 9f180e3

Please sign in to comment.