On Thu, Jul 19, 2018 at 11:39:17AM +0200, Martin Wilck wrote: > If the last page of the bio is not "full", the length of the last > vector slot needs to be corrected. This slot has the index > (bio->bi_vcnt - 1), but only in bio->bi_io_vec. In the "bv" helper > array, which is shifted by the value of bio->bi_vcnt at function > invocation, the correct index is (nr_pages - 1). > > V2: improved readability following suggestions from Ming Lei. > > Fixes: 2cefe4dbaadf ("block: add bio_iov_iter_get_pages()") > Signed-off-by: Martin Wilck <mwilck@xxxxxxxx> > --- > block/bio.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/block/bio.c b/block/bio.c > index 67eff5e..0964328 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -912,16 +912,16 @@ EXPORT_SYMBOL(bio_add_page); > */ > int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) > { > - unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt; > + unsigned short idx, nr_pages = bio->bi_max_vecs - bio->bi_vcnt; Nipick: I prefer to keep the variable(s) that are initialized first on any given line. Otherwise this looks fine: Reviewed-by: Christoph Hellwig <hch@xxxxxx>