From 1798aeb1215623ad5702674e2094c6ca88c844bd Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 23 Apr 2015 13:57:23 +0200 Subject: [PATCH] vdisk_blockio: Set REQ_WRITE flag before invoking bio_add_page() The bio request type must be set before bio_add_page() is invoked. See e.g. raid5_mergeable_bvec() for an example of a function that checks (bi_rw & REQ_WRITE) from inside the bio_add_page() call. This patch improves performance when using SCST on top of RAID5. Signed-off-by: Bart Van Assche --- scst/src/dev_handlers/scst_vdisk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scst/src/dev_handlers/scst_vdisk.c b/scst/src/dev_handlers/scst_vdisk.c index d0b5ed762..baaa35695 100644 --- a/scst/src/dev_handlers/scst_vdisk.c +++ b/scst/src/dev_handlers/scst_vdisk.c @@ -5415,6 +5415,12 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua) * and retries. */ vdisk_bio_set_failfast(bio); + if (write) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36) + bio->bi_rw |= (1 << BIO_RW); +#else + bio->bi_rw |= REQ_WRITE; +#endif #if 0 /* It could be win, but could be not, so a performance study is needed */ bio->bi_rw |= REQ_SYNC; @@ -5465,7 +5471,7 @@ static void blockio_exec_rw(struct vdisk_cmd_params *p, bool write, bool fua) bio = hbio; hbio = hbio->bi_next; bio->bi_next = NULL; - submit_bio((write != 0), bio); + submit_bio(bio->bi_rw, bio); } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)