Skip to contentSkip to conversation

fs/direct-io.c: Set bi_rw when alloc bio.

RFC PATCH In review majianpeng 2 participants 4 messages Jul 27, 2012 – Jul 30, 2012

Subsystems (2)
lore
Share & tools
lore

majianpeng

author
#0 lore raw

RFC PATCH 1/1 fs/direct-io.c: Set bi_rw when alloc bio.

When exec bio_alloc, the bi_rw is zero.But after calling bio_add_page, it will use bi_rw.
Fox example, in functiion __bio_add_page,it will call merge_bvec_fn(). The merge_bvec_fn of raid456 will use the bi_rw to judge the merge.

Quoted 2 lines
Quoted 2 lines

if ((bvm->bi_rw & 1) == WRITE)

		return biovec->bv_len; /* always allow writes to be mergeable */

There are many place like this in kernel.If you think this patch ok, i will correct those.

---
 fs/direct-io.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/direct-io.c +1 -0
index 1faf4cb..77f0bbf 100644
@@ -349,6 +349,7 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
 
 	bio->bi_bdev = bdev;
 	bio->bi_sector = first_sector;
+	bio->bi_rw = dio->rw;
 	if (dio->is_async)
 		bio->bi_end_io = dio_bio_end_aio;
 	else
Signature · 1 line
1.7.5.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · majianpeng

When exec bio_alloc, the bi_rw is zero.But after calling bio_add_page, it will use bi_rw.
Fox example, in functiion __bio_add_page,it will call merge_bvec_fn(). The merge_bvec_fn of raid456 will use the bi_rw to judge the merge.

Quoted 2 lines
Quoted 2 lines

if ((bvm->bi_rw & 1) == WRITE)

		return biovec->bv_len; /* always allow writes to be mergeable */

Good catch. How did you find this? Did you experience data corruption as a result of this oversight, reduced performance due to missed merge opportunities, or did you just notice it in reviewing the code?

Quoted 18 lines

There are many place like this in kernel.If you think this patch ok, i will correct those.

---
 fs/direct-io.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/direct-io.c +1 -0
index 1faf4cb..77f0bbf 100644
@@ -349,6 +349,7 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
 
 	bio->bi_bdev = bdev;
 	bio->bi_sector = first_sector;
+	bio->bi_rw = dio->rw;
 	if (dio->is_async)
 		bio->bi_end_io = dio_bio_end_aio;
 	else
author
#2 lore raw

On 2012-07-27 22:21 Jeff Moyer <[email protected]> Wrote:

Quoted 9 lines
Quoted 7 lines · majianpeng

When exec bio_alloc, the bi_rw is zero.But after calling bio_add_page, it will use bi_rw.
Fox example, in functiion __bio_add_page,it will call merge_bvec_fn(). The merge_bvec_fn of raid456 will use the bi_rw to judge the merge.

Quoted 2 lines
Quoted 2 lines

if ((bvm->bi_rw & 1) == WRITE)

		return biovec->bv_len; /* always allow writes to be mergeable */
Quoted 8 lines
Quoted 1 line

Good catch. How did you find this? Did you experience data corruption as a result of this oversight, reduced performance due to missed merge opportunities, or did you just notice it in reviewing the code?

Sorry for late to reply. When i analysed the performance of raid5, i found this bug.

Quoted 18 lines
Quoted 18 lines

There are many place like this in kernel.If you think this patch ok, i will correct those.

---
 fs/direct-io.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/direct-io.c +1 -0
index 1faf4cb..77f0bbf 100644
@@ -349,6 +349,7 @@ dio_bio_alloc(struct dio *dio, struct dio_submit *sdio,
 
 	bio->bi_bdev = bdev;
 	bio->bi_sector = first_sector;
+	bio->bi_rw = dio->rw;
 	if (dio->is_async)
 		bio->bi_end_io = dio_bio_end_aio;
 	else�翳簕.n�+壏煯壄�+%娝�遍荻w�簕.n�+壏{炳G珴�妠ay�蕠跈�,jf"穐殢飦�戧鐉_璁(殠娸"濟�m���G珴�⒏?櫒璀�&x忈秈O曟瑉窔v豝�m����鹅�⒏?朓�
#3 lore raw
Quoted 12 lines · majianpeng

On 2012-07-27 22:21 Jeff Moyer <[email protected]> Wrote:

Quoted 11 lines
Quoted 8 lines · majianpeng

When exec bio_alloc, the bi_rw is zero.But after calling bio_add_page, it will use bi_rw.
Fox example, in functiion __bio_add_page,it will call merge_bvec_fn(). The merge_bvec_fn of raid456 will use the bi_rw to judge the merge.

Quoted 2 lines
Quoted 2 lines

if ((bvm->bi_rw & 1) == WRITE)

		return biovec->bv_len; /* always allow writes to be mergeable */
Quoted 7 lines
Quoted 6 lines

Good catch. How did you find this? Did you experience data corruption as a result of this oversight, reduced performance due to missed merge opportunities, or did you just notice it in reviewing the code?

Sorry for late to reply. When i analysed the performance of raid5, i found this bug.

OK, thanks. In the future, it would be good to include that information in the patch description.

Cheers,
Jeff