From 16acea8215a0824879d2600f29edf66e63b4b506 Mon Sep 17 00:00:00 2001 From: Joseph Qi Date: Wed, 15 May 2019 16:55:24 +0800 Subject: [PATCH] block: introduce bvec_nth_page() Cherry-pick from upstream commit 4d633062c1c0794a6b3836b7b55afba4599736e8. Single-page bvec can often be seen in small BS workloads, so introduce bvec_nth_page() for avoiding to call nth_page() unnecessarily, which looks not cheap. Signed-off-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Joseph Qi Reviewed-by: Jeffle Xu Acked-by: Caspar Zhang --- include/linux/bvec.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/bvec.h b/include/linux/bvec.h index fe7a22dd133b..66a737c6baa6 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -23,6 +23,7 @@ #include #include #include +#include /* * was unsigned short, but we might as well be ready for > 64kB I/O pages @@ -46,6 +47,11 @@ struct bvec_iter { current bvec */ }; +static inline struct page *bvec_nth_page(struct page *page, int idx) +{ + return idx == 0 ? page : nth_page(page, idx); +} + /* * various member access, note that bio_data should of course not be used * on highmem page vectors -- GitLab