[Devel] [PATCH RHEL7 COMMIT] ploop: dio_fastmap() must refresh bvec_merge_data

Konstantin Khorenko khorenko at virtuozzo.com
Fri Aug 28 03:18:38 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-229.7.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.6.3
------>
commit fc65c834967a14d37ef23348cec6528d18b0a169
Author: Maxim Patlasov <MPatlasov at openvz.org>
Date:   Fri Aug 28 14:18:37 2015 +0400

    ploop: dio_fastmap() must refresh bvec_merge_data
    
    q->merge_bvec_fn() may override some fileds of bvec_merge_data.
    For example, raid0_mergeable_bvec() does so. The blessed way is
    to initialize it from scratch before use -- see how __bio_add_page()
    prepares bvm for calling q->merge_bvec_fn().
    
    Signed-off-by: Maxim Patlasov <MPatlasov at openvz.org>
    Acked-by: Dmitry Monakhov <dmonakhov at openvz.org>
---
 drivers/block/ploop/io_direct.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 793bcc5..0183b0f 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -1487,7 +1487,6 @@ dio_fastmap(struct ploop_io * io, struct bio * orig_bio,
 	struct request_queue * q;
 	struct extent_map * em;
 	int i;
-	struct bvec_merge_data bm_data;
 
 	if (orig_bio->bi_size == 0) {
 		bio->bi_vcnt   = 0;
@@ -1535,19 +1534,19 @@ dio_fastmap(struct ploop_io * io, struct bio * orig_bio,
 	bio->bi_size = 0;
 	bio->bi_vcnt = 0;
 
-	bm_data.bi_bdev = bio->bi_bdev;
-	bm_data.bi_sector = bio->bi_sector;
-	bm_data.bi_size = 0;
-	bm_data.bi_rw = bio->bi_rw;
-
 	for (i = 0; i < orig_bio->bi_vcnt; i++) {
 		struct bio_vec * bv = &bio->bi_io_vec[i];
+		struct bvec_merge_data bm_data = {
+			.bi_bdev = bio->bi_bdev,
+			.bi_sector = bio->bi_sector,
+			.bi_size = bio->bi_size,
+			.bi_rw = bio->bi_rw,
+		};
 		if (q->merge_bvec_fn(q, &bm_data, bv) < bv->bv_len) {
 			io->plo->st.fast_neg_backing++;
 			return 1;
 		}
 		bio->bi_size += bv->bv_len;
-		bm_data.bi_size = bio->bi_size;
 		bio->bi_vcnt++;
 	}
 	return 0;



More information about the Devel mailing list