Commit 802ba064 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds

[PATCH] md: Don't assume that READ==0 and WRITE==1 - use the names explicitly

Thanks Jens for alerting me to this.

Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: <raziebe@gmail.com>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 011e3a9a
...@@ -173,7 +173,7 @@ static int make_request(request_queue_t *q, struct bio *bio) ...@@ -173,7 +173,7 @@ static int make_request(request_queue_t *q, struct bio *bio)
conf_t *conf = (conf_t*)mddev->private; conf_t *conf = (conf_t*)mddev->private;
int failit = 0; int failit = 0;
if (bio->bi_rw & 1) { if (bio_data_dir(bio) == WRITE) {
/* write request */ /* write request */
if (atomic_read(&conf->counters[WriteAll])) { if (atomic_read(&conf->counters[WriteAll])) {
/* special case - don't decrement, don't generic_make_request, /* special case - don't decrement, don't generic_make_request,
......
...@@ -1736,7 +1736,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i ...@@ -1736,7 +1736,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
/* take from bio_init */ /* take from bio_init */
bio->bi_next = NULL; bio->bi_next = NULL;
bio->bi_flags |= 1 << BIO_UPTODATE; bio->bi_flags |= 1 << BIO_UPTODATE;
bio->bi_rw = 0; bio->bi_rw = READ;
bio->bi_vcnt = 0; bio->bi_vcnt = 0;
bio->bi_idx = 0; bio->bi_idx = 0;
bio->bi_phys_segments = 0; bio->bi_phys_segments = 0;
......
...@@ -1785,7 +1785,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i ...@@ -1785,7 +1785,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
biolist = bio; biolist = bio;
bio->bi_private = r10_bio; bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_read; bio->bi_end_io = end_sync_read;
bio->bi_rw = 0; bio->bi_rw = READ;
bio->bi_sector = r10_bio->devs[j].addr + bio->bi_sector = r10_bio->devs[j].addr +
conf->mirrors[d].rdev->data_offset; conf->mirrors[d].rdev->data_offset;
bio->bi_bdev = conf->mirrors[d].rdev->bdev; bio->bi_bdev = conf->mirrors[d].rdev->bdev;
...@@ -1801,7 +1801,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i ...@@ -1801,7 +1801,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
biolist = bio; biolist = bio;
bio->bi_private = r10_bio; bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_write; bio->bi_end_io = end_sync_write;
bio->bi_rw = 1; bio->bi_rw = WRITE;
bio->bi_sector = r10_bio->devs[k].addr + bio->bi_sector = r10_bio->devs[k].addr +
conf->mirrors[i].rdev->data_offset; conf->mirrors[i].rdev->data_offset;
bio->bi_bdev = conf->mirrors[i].rdev->bdev; bio->bi_bdev = conf->mirrors[i].rdev->bdev;
...@@ -1870,7 +1870,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i ...@@ -1870,7 +1870,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
biolist = bio; biolist = bio;
bio->bi_private = r10_bio; bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_read; bio->bi_end_io = end_sync_read;
bio->bi_rw = 0; bio->bi_rw = READ;
bio->bi_sector = r10_bio->devs[i].addr + bio->bi_sector = r10_bio->devs[i].addr +
conf->mirrors[d].rdev->data_offset; conf->mirrors[d].rdev->data_offset;
bio->bi_bdev = conf->mirrors[d].rdev->bdev; bio->bi_bdev = conf->mirrors[d].rdev->bdev;
......
...@@ -1827,16 +1827,16 @@ static void handle_stripe5(struct stripe_head *sh) ...@@ -1827,16 +1827,16 @@ static void handle_stripe5(struct stripe_head *sh)
struct bio *bi; struct bio *bi;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags))
rw = 1; rw = WRITE;
else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags))
rw = 0; rw = READ;
else else
continue; continue;
bi = &sh->dev[i].req; bi = &sh->dev[i].req;
bi->bi_rw = rw; bi->bi_rw = rw;
if (rw) if (rw == WRITE)
bi->bi_end_io = raid5_end_write_request; bi->bi_end_io = raid5_end_write_request;
else else
bi->bi_end_io = raid5_end_read_request; bi->bi_end_io = raid5_end_read_request;
...@@ -1872,7 +1872,7 @@ static void handle_stripe5(struct stripe_head *sh) ...@@ -1872,7 +1872,7 @@ static void handle_stripe5(struct stripe_head *sh)
atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
generic_make_request(bi); generic_make_request(bi);
} else { } else {
if (rw == 1) if (rw == WRITE)
set_bit(STRIPE_DEGRADED, &sh->state); set_bit(STRIPE_DEGRADED, &sh->state);
PRINTK("skip op %ld on disc %d for sector %llu\n", PRINTK("skip op %ld on disc %d for sector %llu\n",
bi->bi_rw, i, (unsigned long long)sh->sector); bi->bi_rw, i, (unsigned long long)sh->sector);
...@@ -2370,16 +2370,16 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page) ...@@ -2370,16 +2370,16 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
struct bio *bi; struct bio *bi;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags)) if (test_and_clear_bit(R5_Wantwrite, &sh->dev[i].flags))
rw = 1; rw = WRITE;
else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags)) else if (test_and_clear_bit(R5_Wantread, &sh->dev[i].flags))
rw = 0; rw = READ;
else else
continue; continue;
bi = &sh->dev[i].req; bi = &sh->dev[i].req;
bi->bi_rw = rw; bi->bi_rw = rw;
if (rw) if (rw == WRITE)
bi->bi_end_io = raid5_end_write_request; bi->bi_end_io = raid5_end_write_request;
else else
bi->bi_end_io = raid5_end_read_request; bi->bi_end_io = raid5_end_read_request;
...@@ -2415,7 +2415,7 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page) ...@@ -2415,7 +2415,7 @@ static void handle_stripe6(struct stripe_head *sh, struct page *tmp_page)
atomic_add(STRIPE_SECTORS, &rdev->corrected_errors); atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
generic_make_request(bi); generic_make_request(bi);
} else { } else {
if (rw == 1) if (rw == WRITE)
set_bit(STRIPE_DEGRADED, &sh->state); set_bit(STRIPE_DEGRADED, &sh->state);
PRINTK("skip op %ld on disc %d for sector %llu\n", PRINTK("skip op %ld on disc %d for sector %llu\n",
bi->bi_rw, i, (unsigned long long)sh->sector); bi->bi_rw, i, (unsigned long long)sh->sector);
...@@ -2567,7 +2567,7 @@ static int raid5_mergeable_bvec(request_queue_t *q, struct bio *bio, struct bio_ ...@@ -2567,7 +2567,7 @@ static int raid5_mergeable_bvec(request_queue_t *q, struct bio *bio, struct bio_
unsigned int chunk_sectors = mddev->chunk_size >> 9; unsigned int chunk_sectors = mddev->chunk_size >> 9;
unsigned int bio_sectors = bio->bi_size >> 9; unsigned int bio_sectors = bio->bi_size >> 9;
if (bio_data_dir(bio)) if (bio_data_dir(bio) == WRITE)
return biovec->bv_len; /* always allow writes to be mergeable */ return biovec->bv_len; /* always allow writes to be mergeable */
max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9; max = (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) << 9;
...@@ -2751,7 +2751,7 @@ static int make_request(request_queue_t *q, struct bio * bi) ...@@ -2751,7 +2751,7 @@ static int make_request(request_queue_t *q, struct bio * bi)
disk_stat_inc(mddev->gendisk, ios[rw]); disk_stat_inc(mddev->gendisk, ios[rw]);
disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bi)); disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bi));
if (bio_data_dir(bi) == READ && if (rw == READ &&
mddev->reshape_position == MaxSector && mddev->reshape_position == MaxSector &&
chunk_aligned_read(q,bi)) chunk_aligned_read(q,bi))
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment