]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
block: take destination bvec offsets into account in bio_copy_data_iter
authorChristoph Hellwig <hch@lst.de>
Tue, 24 May 2022 14:39:19 +0000 (16:39 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 26 Aug 2022 08:52:47 +0000 (10:52 +0200)
BugLink: https://bugs.launchpad.net/bugs/1982968
[ Upstream commit 403d50341cce6b5481a92eb481e6df60b1f49b55 ]

Appartly bcache can copy into bios that do not just contain fresh
pages but can have offsets into the bio_vecs.  Restore support for tht
in bio_copy_data_iter.

Fixes: f8b679a070c5 ("block: rewrite bio_copy_data_iter to use bvec_kmap_local and memcpy_to_bvec")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220524143919.1155501-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
block/bio.c

index 8906c9856a7dee9b3f5f537f2415e76be63b867a..9b28381412d2307bf633c1a527731fe38d07513b 100644 (file)
@@ -1289,10 +1289,12 @@ void bio_copy_data_iter(struct bio *dst, struct bvec_iter *dst_iter,
                struct bio_vec src_bv = bio_iter_iovec(src, *src_iter);
                struct bio_vec dst_bv = bio_iter_iovec(dst, *dst_iter);
                unsigned int bytes = min(src_bv.bv_len, dst_bv.bv_len);
-               void *src_buf;
+               void *src_buf = bvec_kmap_local(&src_bv);
+               void *dst_buf = bvec_kmap_local(&dst_bv);
 
-               src_buf = bvec_kmap_local(&src_bv);
-               memcpy_to_bvec(&dst_bv, src_buf);
+               memcpy(dst_buf, src_buf, bytes);
+
+               kunmap_local(dst_buf);
                kunmap_local(src_buf);
 
                bio_advance_iter_single(src, src_iter, bytes);