Re: [PATCH] raid-1/10: fix RW bits manipulation

From: Neil Brown
Date: Wed Sep 23 2009 - 04:23:33 EST


On Sunday September 20, rjevskiy@xxxxxxxxx wrote:
> Recently Jens has changed bio_rw_flagged() logic by following
> commit 1f98a13f623e0ef666690a18c1250335fc6d7ef1. Now it returns
> bool instead of int. This broke raid1/raid10 RW bits manipulation logic.
> One of visible result is BUG_ON triggering due to empty barrier
> here scsi_lib.c:1108 scsi_setup_fs_cmnd()

Thanks for this. It looks good. I will forward it to Linus shortly.

NeilBrown


>
> Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx>
> ---
> drivers/md/raid1.c | 10 ++++++----
> drivers/md/raid10.c | 6 +++---
> 2 files changed, 9 insertions(+), 7 deletions(-)
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index ff7ed33..5de48e5 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -851,7 +851,7 @@ static int make_request(struct request_queue *q, struct bio * bio)
> read_bio->bi_sector = r1_bio->sector + mirror->rdev->data_offset;
> read_bio->bi_bdev = mirror->rdev->bdev;
> read_bio->bi_end_io = raid1_end_read_request;
> - read_bio->bi_rw = READ | do_sync;
> + read_bio->bi_rw = READ | (do_sync << BIO_RW_SYNCIO);
> read_bio->bi_private = r1_bio;
>
> generic_make_request(read_bio);
> @@ -943,7 +943,8 @@ static int make_request(struct request_queue *q, struct bio * bio)
> mbio->bi_sector = r1_bio->sector + conf->mirrors[i].rdev->data_offset;
> mbio->bi_bdev = conf->mirrors[i].rdev->bdev;
> mbio->bi_end_io = raid1_end_write_request;
> - mbio->bi_rw = WRITE | do_barriers | do_sync;
> + mbio->bi_rw = WRITE | (do_barriers << BIO_RW_BARRIER) |
> + (do_sync << BIO_RW_SYNCIO);
> mbio->bi_private = r1_bio;
>
> if (behind_pages) {
> @@ -1623,7 +1624,8 @@ static void raid1d(mddev_t *mddev)
> conf->mirrors[i].rdev->data_offset;
> bio->bi_bdev = conf->mirrors[i].rdev->bdev;
> bio->bi_end_io = raid1_end_write_request;
> - bio->bi_rw = WRITE | do_sync;
> + bio->bi_rw = WRITE |
> + (do_sync << BIO_RW_SYNCIO);
> bio->bi_private = r1_bio;
> r1_bio->bios[i] = bio;
> generic_make_request(bio);
> @@ -1672,7 +1674,7 @@ static void raid1d(mddev_t *mddev)
> bio->bi_sector = r1_bio->sector + rdev->data_offset;
> bio->bi_bdev = rdev->bdev;
> bio->bi_end_io = raid1_end_read_request;
> - bio->bi_rw = READ | do_sync;
> + bio->bi_rw = READ | (do_sync << BIO_RW_SYNCIO);
> bio->bi_private = r1_bio;
> unplug = 1;
> generic_make_request(bio);
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index d0a2152..f2c891f 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -882,7 +882,7 @@ static int make_request(struct request_queue *q, struct bio * bio)
> mirror->rdev->data_offset;
> read_bio->bi_bdev = mirror->rdev->bdev;
> read_bio->bi_end_io = raid10_end_read_request;
> - read_bio->bi_rw = READ | do_sync;
> + read_bio->bi_rw = READ | (do_sync << BIO_RW_SYNCIO);
> read_bio->bi_private = r10_bio;
>
> generic_make_request(read_bio);
> @@ -950,7 +950,7 @@ static int make_request(struct request_queue *q, struct bio * bio)
> conf->mirrors[d].rdev->data_offset;
> mbio->bi_bdev = conf->mirrors[d].rdev->bdev;
> mbio->bi_end_io = raid10_end_write_request;
> - mbio->bi_rw = WRITE | do_sync;
> + mbio->bi_rw = WRITE | (do_sync << BIO_RW_SYNCIO);
> mbio->bi_private = r10_bio;
>
> atomic_inc(&r10_bio->remaining);
> @@ -1623,7 +1623,7 @@ static void raid10d(mddev_t *mddev)
> bio->bi_sector = r10_bio->devs[r10_bio->read_slot].addr
> + rdev->data_offset;
> bio->bi_bdev = rdev->bdev;
> - bio->bi_rw = READ | do_sync;
> + bio->bi_rw = READ | (do_sync << BIO_RW_SYNCIO);
> bio->bi_private = r10_bio;
> bio->bi_end_io = raid10_end_read_request;
> unplug = 1;
> --
> 1.6.2.2.446.gfbdc0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/