aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bio.h
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-01-09 16:03:03 +0000
committerJens Axboe <axboe@kernel.dk>2021-01-25 08:58:24 -0700
commitc42bca92be928ce7dece5fc04cf68d0e37ee6718 (patch)
tree132b3485f416fde3c9d57e9003f826fcb5583d75 /include/linux/bio.h
parentbio: add a helper calculating nr segments to alloc (diff)
downloadlinux-dev-c42bca92be928ce7dece5fc04cf68d0e37ee6718.tar.xz
linux-dev-c42bca92be928ce7dece5fc04cf68d0e37ee6718.zip
bio: don't copy bvec for direct IO
The block layer spends quite a while in blkdev_direct_IO() to copy and initialise bio's bvec. However, if we've already got a bvec in the input iterator it might be reused in some cases, i.e. when new ITER_BVEC_FLAG_FIXED flag is set. Simple tests show considerable performance boost, and it also reduces memory footprint. Suggested-by: Matthew Wilcox <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/bio.h')
-rw-r--r--include/linux/bio.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 9ddb19801a03..676870b2c88d 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -444,10 +444,13 @@ static inline void bio_wouldblock_error(struct bio *bio)
/*
* Calculate number of bvec segments that should be allocated to fit data
- * pointed by @iter.
+ * pointed by @iter. If @iter is backed by bvec it's going to be reused
+ * instead of allocating a new one.
*/
static inline int bio_iov_vecs_to_alloc(struct iov_iter *iter, int max_segs)
{
+ if (iov_iter_is_bvec(iter))
+ return 0;
return iov_iter_npages(iter, max_segs);
}