Commit ccebd4c4 authored by Jonathan Brassow's avatar Jonathan Brassow Committed by NeilBrown

md-new-param-to_sync_page_io

Add new parameter to 'sync_page_io'.

The new parameter allows us to distinguish between metadata and data
operations.  This becomes important later when we add the ability to
use separate devices for data and metadata.
Signed-off-by: default avatarJonathan Brassow <jbrassow@redhat.com>
parent 57b2caa3
...@@ -210,11 +210,11 @@ static struct page *read_sb_page(mddev_t *mddev, loff_t offset, ...@@ -210,11 +210,11 @@ static struct page *read_sb_page(mddev_t *mddev, loff_t offset,
|| test_bit(Faulty, &rdev->flags)) || test_bit(Faulty, &rdev->flags))
continue; continue;
target = rdev->sb_start + offset + index * (PAGE_SIZE/512); target = offset + index * (PAGE_SIZE/512);
if (sync_page_io(rdev, target, if (sync_page_io(rdev, target,
roundup(size, bdev_logical_block_size(rdev->bdev)), roundup(size, bdev_logical_block_size(rdev->bdev)),
page, READ)) { page, READ, true)) {
page->index = index; page->index = index;
attach_page_buffers(page, NULL); /* so that free_buffer will attach_page_buffers(page, NULL); /* so that free_buffer will
* quietly no-op */ * quietly no-op */
......
...@@ -795,7 +795,7 @@ static void bi_complete(struct bio *bio, int error) ...@@ -795,7 +795,7 @@ static void bi_complete(struct bio *bio, int error)
} }
int sync_page_io(mdk_rdev_t *rdev, sector_t sector, int size, int sync_page_io(mdk_rdev_t *rdev, sector_t sector, int size,
struct page *page, int rw) struct page *page, int rw, bool metadata_op)
{ {
struct bio *bio = bio_alloc_mddev(GFP_NOIO, 1, rdev->mddev); struct bio *bio = bio_alloc_mddev(GFP_NOIO, 1, rdev->mddev);
struct completion event; struct completion event;
...@@ -804,7 +804,10 @@ int sync_page_io(mdk_rdev_t *rdev, sector_t sector, int size, ...@@ -804,7 +804,10 @@ int sync_page_io(mdk_rdev_t *rdev, sector_t sector, int size,
rw |= REQ_SYNC | REQ_UNPLUG; rw |= REQ_SYNC | REQ_UNPLUG;
bio->bi_bdev = rdev->bdev; bio->bi_bdev = rdev->bdev;
bio->bi_sector = sector; if (metadata_op)
bio->bi_sector = sector + rdev->sb_start;
else
bio->bi_sector = sector + rdev->data_offset;
bio_add_page(bio, page, size, 0); bio_add_page(bio, page, size, 0);
init_completion(&event); init_completion(&event);
bio->bi_private = &event; bio->bi_private = &event;
...@@ -829,7 +832,7 @@ static int read_disk_sb(mdk_rdev_t * rdev, int size) ...@@ -829,7 +832,7 @@ static int read_disk_sb(mdk_rdev_t * rdev, int size)
return 0; return 0;
if (!sync_page_io(rdev, rdev->sb_start, size, rdev->sb_page, READ)) if (!sync_page_io(rdev, 0, size, rdev->sb_page, READ, true))
goto fail; goto fail;
rdev->sb_loaded = 1; rdev->sb_loaded = 1;
return 0; return 0;
......
...@@ -498,8 +498,8 @@ extern void md_flush_request(mddev_t *mddev, struct bio *bio); ...@@ -498,8 +498,8 @@ extern void md_flush_request(mddev_t *mddev, struct bio *bio);
extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev, extern void md_super_write(mddev_t *mddev, mdk_rdev_t *rdev,
sector_t sector, int size, struct page *page); sector_t sector, int size, struct page *page);
extern void md_super_wait(mddev_t *mddev); extern void md_super_wait(mddev_t *mddev);
extern int sync_page_io(mdk_rdev_t *rdev, sector_t sector, int size, extern int sync_page_io(mdk_rdev_t *rdev, sector_t sector, int size,
struct page *page, int rw); struct page *page, int rw, bool metadata_op);
extern void md_do_sync(mddev_t *mddev); extern void md_do_sync(mddev_t *mddev);
extern void md_new_event(mddev_t *mddev); extern void md_new_event(mddev_t *mddev);
extern int md_allow_write(mddev_t *mddev); extern int md_allow_write(mddev_t *mddev);
......
...@@ -1365,10 +1365,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) ...@@ -1365,10 +1365,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
*/ */
rdev = conf->mirrors[d].rdev; rdev = conf->mirrors[d].rdev;
if (sync_page_io(rdev, if (sync_page_io(rdev,
sect + rdev->data_offset, sect,
s<<9, s<<9,
bio->bi_io_vec[idx].bv_page, bio->bi_io_vec[idx].bv_page,
READ)) { READ, false)) {
success = 1; success = 1;
break; break;
} }
...@@ -1391,10 +1391,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) ...@@ -1391,10 +1391,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
rdev = conf->mirrors[d].rdev; rdev = conf->mirrors[d].rdev;
atomic_add(s, &rdev->corrected_errors); atomic_add(s, &rdev->corrected_errors);
if (sync_page_io(rdev, if (sync_page_io(rdev,
sect + rdev->data_offset, sect,
s<<9, s<<9,
bio->bi_io_vec[idx].bv_page, bio->bi_io_vec[idx].bv_page,
WRITE) == 0) WRITE, false) == 0)
md_error(mddev, rdev); md_error(mddev, rdev);
} }
d = start; d = start;
...@@ -1406,10 +1406,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) ...@@ -1406,10 +1406,10 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
continue; continue;
rdev = conf->mirrors[d].rdev; rdev = conf->mirrors[d].rdev;
if (sync_page_io(rdev, if (sync_page_io(rdev,
sect + rdev->data_offset, sect,
s<<9, s<<9,
bio->bi_io_vec[idx].bv_page, bio->bi_io_vec[idx].bv_page,
READ) == 0) READ, false) == 0)
md_error(mddev, rdev); md_error(mddev, rdev);
} }
} else { } else {
...@@ -1489,10 +1489,8 @@ static void fix_read_error(conf_t *conf, int read_disk, ...@@ -1489,10 +1489,8 @@ static void fix_read_error(conf_t *conf, int read_disk,
rdev = conf->mirrors[d].rdev; rdev = conf->mirrors[d].rdev;
if (rdev && if (rdev &&
test_bit(In_sync, &rdev->flags) && test_bit(In_sync, &rdev->flags) &&
sync_page_io(rdev, sync_page_io(rdev, sect, s<<9,
sect + rdev->data_offset, conf->tmppage, READ, false))
s<<9,
conf->tmppage, READ))
success = 1; success = 1;
else { else {
d++; d++;
...@@ -1515,9 +1513,8 @@ static void fix_read_error(conf_t *conf, int read_disk, ...@@ -1515,9 +1513,8 @@ static void fix_read_error(conf_t *conf, int read_disk,
rdev = conf->mirrors[d].rdev; rdev = conf->mirrors[d].rdev;
if (rdev && if (rdev &&
test_bit(In_sync, &rdev->flags)) { test_bit(In_sync, &rdev->flags)) {
if (sync_page_io(rdev, if (sync_page_io(rdev, sect, s<<9,
sect + rdev->data_offset, conf->tmppage, WRITE, false)
s<<9, conf->tmppage, WRITE)
== 0) == 0)
/* Well, this device is dead */ /* Well, this device is dead */
md_error(mddev, rdev); md_error(mddev, rdev);
...@@ -1532,9 +1529,8 @@ static void fix_read_error(conf_t *conf, int read_disk, ...@@ -1532,9 +1529,8 @@ static void fix_read_error(conf_t *conf, int read_disk,
rdev = conf->mirrors[d].rdev; rdev = conf->mirrors[d].rdev;
if (rdev && if (rdev &&
test_bit(In_sync, &rdev->flags)) { test_bit(In_sync, &rdev->flags)) {
if (sync_page_io(rdev, if (sync_page_io(rdev, sect, s<<9,
sect + rdev->data_offset, conf->tmppage, READ, false)
s<<9, conf->tmppage, READ)
== 0) == 0)
/* Well, this device is dead */ /* Well, this device is dead */
md_error(mddev, rdev); md_error(mddev, rdev);
......
...@@ -1560,9 +1560,9 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio) ...@@ -1560,9 +1560,9 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
rcu_read_unlock(); rcu_read_unlock();
success = sync_page_io(rdev, success = sync_page_io(rdev,
r10_bio->devs[sl].addr + r10_bio->devs[sl].addr +
sect + rdev->data_offset, sect,
s<<9, s<<9,
conf->tmppage, READ); conf->tmppage, READ, false);
rdev_dec_pending(rdev, mddev); rdev_dec_pending(rdev, mddev);
rcu_read_lock(); rcu_read_lock();
if (success) if (success)
...@@ -1599,8 +1599,8 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio) ...@@ -1599,8 +1599,8 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
atomic_add(s, &rdev->corrected_errors); atomic_add(s, &rdev->corrected_errors);
if (sync_page_io(rdev, if (sync_page_io(rdev,
r10_bio->devs[sl].addr + r10_bio->devs[sl].addr +
sect + rdev->data_offset, sect,
s<<9, conf->tmppage, WRITE) s<<9, conf->tmppage, WRITE, false)
== 0) { == 0) {
/* Well, this device is dead */ /* Well, this device is dead */
printk(KERN_NOTICE printk(KERN_NOTICE
...@@ -1636,9 +1636,9 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio) ...@@ -1636,9 +1636,9 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
rcu_read_unlock(); rcu_read_unlock();
if (sync_page_io(rdev, if (sync_page_io(rdev,
r10_bio->devs[sl].addr + r10_bio->devs[sl].addr +
sect + rdev->data_offset, sect,
s<<9, conf->tmppage, s<<9, conf->tmppage,
READ) == 0) { READ, false) == 0) {
/* Well, this device is dead */ /* Well, this device is dead */
printk(KERN_NOTICE printk(KERN_NOTICE
"md/raid10:%s: unable to read back " "md/raid10:%s: unable to read back "
......
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