Skip to content

Commit e80fd7a

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: remove bvec_free
bvec_free is only called by bio_free, so inline it there. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> -ck Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Link: https://patch.msgid.link/20260316161144.1607877-4-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b520c4e commit e80fd7a

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

block/bio.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,6 @@ static void bio_put_slab(struct bio_set *bs)
161161
mutex_unlock(&bio_slab_lock);
162162
}
163163

164-
static void bvec_free(struct mempool *pool, struct bio_vec *bv,
165-
unsigned short nr_vecs)
166-
{
167-
BUG_ON(nr_vecs > BIO_MAX_VECS);
168-
169-
if (nr_vecs == BIO_MAX_VECS)
170-
mempool_free(bv, pool);
171-
else if (nr_vecs > BIO_INLINE_VECS)
172-
kmem_cache_free(biovec_slab(nr_vecs)->slab, bv);
173-
}
174-
175164
/*
176165
* Make the first allocation restricted and don't dump info on allocation
177166
* failures, since we'll fall back to the mempool in case of failure.
@@ -203,9 +192,14 @@ static void bio_free(struct bio *bio)
203192
void *p = bio;
204193

205194
WARN_ON_ONCE(!bs);
195+
WARN_ON_ONCE(bio->bi_max_vecs > BIO_MAX_VECS);
206196

207197
bio_uninit(bio);
208-
bvec_free(&bs->bvec_pool, bio->bi_io_vec, bio->bi_max_vecs);
198+
if (bio->bi_max_vecs == BIO_MAX_VECS)
199+
mempool_free(bio->bi_io_vec, &bs->bvec_pool);
200+
else if (bio->bi_max_vecs > BIO_INLINE_VECS)
201+
kmem_cache_free(biovec_slab(bio->bi_max_vecs)->slab,
202+
bio->bi_io_vec);
209203
mempool_free(p - bs->front_pad, &bs->bio_pool);
210204
}
211205

@@ -561,7 +555,7 @@ struct bio *bio_alloc_bioset(struct block_device *bdev, unsigned short nr_vecs,
561555

562556
/*
563557
* Upgrade nr_vecs to take full advantage of the allocation.
564-
* We also rely on this in bvec_free().
558+
* We also rely on this in bio_free().
565559
*/
566560
nr_vecs = bvs->nr_vecs;
567561
bvecs = kmem_cache_alloc(bvs->slab, gfp);

0 commit comments

Comments
 (0)