Skip to contentSkip to conversation

fix small highmem bio bounce bvec handling glitch

PATCH In review Christophe Saout 2 participants 4 messages Feb 26, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix small highmem bio bounce bvec handling glitch

Hi,

[Oops, forgot to Cc LKML]

while going through the bio highmem handling code I noticed a small glitch. __end_that_request_first might modify the bv_offset and bv_len if the segment was partially completed. The bio-read-bounce-back code should use the unmodified bv_offset when copying the segment data:

mm/highmem.c +6 -1
@@ -294,7 +294,12 @@
 		if (tovec->bv_page == fromvec->bv_page)
 			continue;
 
-		vfrom = page_address(fromvec->bv_page) + fromvec->bv_offset;
+		/*
+		 * fromvec->bv_offset and fromvec->bv_len might have been
+		 * modified by the block layer, so use the original copy,
+		 * bounce_copy_vec already uses tovec->bv_len
+		 */
+		vfrom = page_address(fromvec->bv_page) + tovec->bv_offset;
 
 		bounce_copy_vec(tovec, vfrom);
 	}
#1 lore raw
Quoted 14 lines · Christophe Saout

Hi,

[Oops, forgot to Cc LKML]

while going through the bio highmem handling code I noticed a small glitch. __end_that_request_first might modify the bv_offset and bv_len if the segment was partially completed. The bio-read-bounce-back code should use the unmodified bv_offset when copying the segment data:

mm/highmem.c +0 -0
@@ -294,7 +294,12 @@
 		if (tovec->bv_page == fromvec->bv_page)
 			continue;

mm/highmem.c line 304

Quoted 10 lines
mm/highmem.c +6 -1
 
-		vfrom = page_address(fromvec->bv_page) + fromvec->bv_offset;
+		/*
+		 * fromvec->bv_offset and fromvec->bv_len might have been
+		 * modified by the block layer, so use the original copy,
+		 * bounce_copy_vec already uses tovec->bv_len
+		 */
+		vfrom = page_address(fromvec->bv_page) + tovec->bv_offset;
 
 		bounce_copy_vec(tovec, vfrom);

Irk yes, that's is pretty nasty, I really wish we could avoid screwing with vec entries (it's pretty obscure for bio clones, too)... Fix is correct, and good idea to add the comment!

Signature · 1 line
Jens Axboe
#2 lore raw

Am Do, den 26.02.2004 schrieb Jens Axboe um 16:10:

Quoted 14 lines
Quoted 14 lines
mm/highmem.c +6 -1
@@ -294,7 +294,12 @@
 		if (tovec->bv_page == fromvec->bv_page)
 			continue;
 
-		vfrom = page_address(fromvec->bv_page) + fromvec->bv_offset;
+		/*
+		 * fromvec->bv_offset and fromvec->bv_len might have been
+		 * modified by the block layer, so use the original copy,
+		 * bounce_copy_vec already uses tovec->bv_len
+		 */
+		vfrom = page_address(fromvec->bv_page) + tovec->bv_offset;
 
Quoted 4 lines

mm/highmem.c line 304

Quoted 1 line
mm/highmem.c +0 -0
 		bounce_copy_vec(tovec, vfrom);

Irk yes, that's is pretty nasty, I really wish we could avoid screwing with vec entries

What about a bio->bi_bvec_done field?

Quoted 1 line

(it's pretty obscure for bio clones, too)...

Yes, I noticed that dm-crypt also does the same mistake for reads. I'm going to change it too (easily accomplished).

#3 lore raw
Quoted 16 lines · Christophe Saout

Am Do, den 26.02.2004 schrieb Jens Axboe um 16:10:

Quoted 14 lines
Quoted 14 lines
mm/highmem.c +6 -1
@@ -294,7 +294,12 @@
 		if (tovec->bv_page == fromvec->bv_page)
 			continue;
 
-		vfrom = page_address(fromvec->bv_page) + fromvec->bv_offset;
+		/*
+		 * fromvec->bv_offset and fromvec->bv_len might have been
+		 * modified by the block layer, so use the original copy,
+		 * bounce_copy_vec already uses tovec->bv_len
+		 */
+		vfrom = page_address(fromvec->bv_page) + tovec->bv_offset;
 
Quoted 6 lines
Quoted 4 lines

mm/highmem.c line 304

Quoted 1 line
mm/highmem.c +0 -0
 		bounce_copy_vec(tovec, vfrom);

Irk yes, that's is pretty nasty, I really wish we could avoid screwing with vec entries

What about a bio->bi_bvec_done field?

That'd work. Suparna originally suggested bio->bi_voffset (iirc) as a current offset. It just doesn't feel completely right...

Quoted 4 lines
Quoted 1 line

(it's pretty obscure for bio clones, too)...

Yes, I noticed that dm-crypt also does the same mistake for reads. I'm going to change it too (easily accomplished).

Great.

Signature · 1 line
Jens Axboe