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>
This commit is contained in:
committed by
Jens Axboe
parent
3e1a88ec96
commit
c42bca92be
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user