block: bio: introduce helpers to get the 1st and last bvec
authorMing Lei <ming.lei@canonical.com>
Fri, 26 Feb 2016 15:40:50 +0000 (23:40 +0800)
committerJens Axboe <axboe@fb.com>
Thu, 3 Mar 2016 21:42:49 +0000 (14:42 -0700)
commit7bcd79ac50d9d83350a835bdb91c04ac9e098412
treeb8161854b8ec9825e7b9fabf2299231130eaf574
parente3c2ef41f88e50c8557270868600d3132028af3b
block: bio: introduce helpers to get the 1st and last bvec

The bio passed to bio_will_gap() may be fast cloned from upper
layer(dm, md, bcache, fs, ...), or from bio splitting in block
core.

Unfortunately bio_will_gap() just figures out the last bvec via
'bi_io_vec[prev->bi_vcnt - 1]' directly, and this way is obviously
wrong.

This patch introduces two helpers for getting the first and last
bvec of one bio for fixing the issue.

Cc: stable@vger.kernel.org
Reported-by: Sagi Grimberg <sagig@dev.mellanox.co.il>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
include/linux/bio.h