* [PATCH v3 0/2] Reorganize raid*_make_request to clean up code
@ 2016-12-05 20:02 Robert LeBlanc
2016-12-05 20:02 ` [PATCH v3 1/2] md/raid1: Refactor raid1_make_request Robert LeBlanc
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Robert LeBlanc @ 2016-12-05 20:02 UTC (permalink / raw)
To: linux-raid; +Cc: Robert LeBlanc
In response to Christoph, I've broken the read and writes into their own
functions to make the code even cleaner. Since it is such a big change, I broke
up the commits into this series instead of creating a v2 of the previous patch.
Changes since v2:
Shaohua Li
* Make md_write_start before wait_barrier
* Move I/O in recovery stripe test to write path
* Changed to if/then instead of return in __make_request
Changes since v1:
John Stoffel
* Changed to if/then instead of return in raid1_make_request
Neil Brown
* Moved wait_barrier into raid1_{read,write}_request so that it could be after
->suspend_{hi,lo}. This prevents a write blocking a resync until the suspend
region is moved.
Robert LeBlanc (2):
md/raid1: Refactor raid1_make_request
md/raid10: Refactor raid10_make_request
drivers/md/raid1.c | 259 +++++++++++++++++++++++++++-------------------------
drivers/md/raid10.c | 215 ++++++++++++++++++++++---------------------
2 files changed, 245 insertions(+), 229 deletions(-)
--
2.10.2
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH v3 1/2] md/raid1: Refactor raid1_make_request 2016-12-05 20:02 [PATCH v3 0/2] Reorganize raid*_make_request to clean up code Robert LeBlanc @ 2016-12-05 20:02 ` Robert LeBlanc 2016-12-05 20:02 ` [PATCH v3 2/2] md/raid10: Refactor raid10_make_request Robert LeBlanc 2016-12-05 20:04 ` [PATCH v3 0/2] Reorganize raid*_make_request to clean up code Robert LeBlanc 2 siblings, 0 replies; 6+ messages in thread From: Robert LeBlanc @ 2016-12-05 20:02 UTC (permalink / raw) To: linux-raid; +Cc: Robert LeBlanc Refactor raid1_make_request to make read and write code in their own functions to clean up the code. Signed-off-by: Robert LeBlanc <robert@leblancnet.us> --- drivers/md/raid1.c | 259 +++++++++++++++++++++++++++-------------------------- 1 file changed, 134 insertions(+), 125 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 94e0afc..4edefb2 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1066,17 +1066,106 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule) kfree(plug); } -static void raid1_make_request(struct mddev *mddev, struct bio * bio) +static void raid1_read_request(struct mddev *mddev, struct bio *bio, + struct r1bio *r1_bio) { struct r1conf *conf = mddev->private; struct raid1_info *mirror; - struct r1bio *r1_bio; struct bio *read_bio; + struct bitmap *bitmap = mddev->bitmap; + const int op = bio_op(bio); + const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); + int sectors_handled; + int max_sectors; + int rdisk; + + wait_barrier(conf, bio); + +read_again: + rdisk = read_balance(conf, r1_bio, &max_sectors); + + if (rdisk < 0) { + /* couldn't find anywhere to read from */ + raid_end_bio_io(r1_bio); + return; + } + mirror = conf->mirrors + rdisk; + + if (test_bit(WriteMostly, &mirror->rdev->flags) && + bitmap) { + /* Reading from a write-mostly device must + * take care not to over-take any writes + * that are 'behind' + */ + raid1_log(mddev, "wait behind writes"); + wait_event(bitmap->behind_wait, + atomic_read(&bitmap->behind_writes) == 0); + } + r1_bio->read_disk = rdisk; + r1_bio->start_next_window = 0; + + read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev); + bio_trim(read_bio, r1_bio->sector - bio->bi_iter.bi_sector, + max_sectors); + + r1_bio->bios[rdisk] = read_bio; + + read_bio->bi_iter.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; + bio_set_op_attrs(read_bio, op, do_sync); + if (test_bit(FailFast, &mirror->rdev->flags) && + test_bit(R1BIO_FailFast, &r1_bio->state)) + read_bio->bi_opf |= MD_FAILFAST; + read_bio->bi_private = r1_bio; + + if (mddev->gendisk) + trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev), + read_bio, disk_devt(mddev->gendisk), + r1_bio->sector); + + if (max_sectors < r1_bio->sectors) { + /* could not read all from this device, so we will + * need another r1_bio. + */ + + sectors_handled = (r1_bio->sector + max_sectors + - bio->bi_iter.bi_sector); + r1_bio->sectors = max_sectors; + spin_lock_irq(&conf->device_lock); + if (bio->bi_phys_segments == 0) + bio->bi_phys_segments = 2; + else + bio->bi_phys_segments++; + spin_unlock_irq(&conf->device_lock); + /* Cannot call generic_make_request directly + * as that will be queued in __make_request + * and subsequent mempool_alloc might block waiting + * for it. So hand bio over to raid1d. + */ + reschedule_retry(r1_bio); + + r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); + + r1_bio->master_bio = bio; + r1_bio->sectors = bio_sectors(bio) - sectors_handled; + r1_bio->state = 0; + r1_bio->mddev = mddev; + r1_bio->sector = bio->bi_iter.bi_sector + sectors_handled; + goto read_again; + } else + generic_make_request(read_bio); +} + +static void raid1_write_request(struct mddev *mddev, struct bio *bio, + struct r1bio *r1_bio) +{ + struct r1conf *conf = mddev->private; int i, disks; - struct bitmap *bitmap; + struct bitmap *bitmap = mddev->bitmap; unsigned long flags; const int op = bio_op(bio); - const int rw = bio_data_dir(bio); const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); const unsigned long do_flush_fua = (bio->bi_opf & (REQ_PREFLUSH | REQ_FUA)); @@ -1096,12 +1185,11 @@ static void raid1_make_request(struct mddev *mddev, struct bio * bio) md_write_start(mddev, bio); /* wait on superblock update early */ - if (bio_data_dir(bio) == WRITE && - ((bio_end_sector(bio) > mddev->suspend_lo && + if ((bio_end_sector(bio) > mddev->suspend_lo && bio->bi_iter.bi_sector < mddev->suspend_hi) || (mddev_is_clustered(mddev) && md_cluster_ops->area_resyncing(mddev, WRITE, - bio->bi_iter.bi_sector, bio_end_sector(bio))))) { + bio->bi_iter.bi_sector, bio_end_sector(bio)))) { /* As the suspend_* range is controlled by * userspace, we want an interruptible * wait. @@ -1115,128 +1203,15 @@ static void raid1_make_request(struct mddev *mddev, struct bio * bio) bio->bi_iter.bi_sector >= mddev->suspend_hi || (mddev_is_clustered(mddev) && !md_cluster_ops->area_resyncing(mddev, WRITE, - bio->bi_iter.bi_sector, bio_end_sector(bio)))) + bio->bi_iter.bi_sector, + bio_end_sector(bio)))) break; schedule(); } finish_wait(&conf->wait_barrier, &w); } - start_next_window = wait_barrier(conf, bio); - bitmap = mddev->bitmap; - - /* - * make_request() can abort the operation when read-ahead is being - * used and no empty request is available. - * - */ - r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); - - r1_bio->master_bio = bio; - r1_bio->sectors = bio_sectors(bio); - r1_bio->state = 0; - r1_bio->mddev = mddev; - r1_bio->sector = bio->bi_iter.bi_sector; - - /* We might need to issue multiple reads to different - * devices if there are bad blocks around, so we keep - * track of the number of reads in bio->bi_phys_segments. - * If this is 0, there is only one r1_bio and no locking - * will be needed when requests complete. If it is - * non-zero, then it is the number of not-completed requests. - */ - bio->bi_phys_segments = 0; - bio_clear_flag(bio, BIO_SEG_VALID); - - if (rw == READ) { - /* - * read balancing logic: - */ - int rdisk; - -read_again: - rdisk = read_balance(conf, r1_bio, &max_sectors); - - if (rdisk < 0) { - /* couldn't find anywhere to read from */ - raid_end_bio_io(r1_bio); - return; - } - mirror = conf->mirrors + rdisk; - - if (test_bit(WriteMostly, &mirror->rdev->flags) && - bitmap) { - /* Reading from a write-mostly device must - * take care not to over-take any writes - * that are 'behind' - */ - raid1_log(mddev, "wait behind writes"); - wait_event(bitmap->behind_wait, - atomic_read(&bitmap->behind_writes) == 0); - } - r1_bio->read_disk = rdisk; - r1_bio->start_next_window = 0; - - read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev); - bio_trim(read_bio, r1_bio->sector - bio->bi_iter.bi_sector, - max_sectors); - - r1_bio->bios[rdisk] = read_bio; - - read_bio->bi_iter.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; - bio_set_op_attrs(read_bio, op, do_sync); - if (test_bit(FailFast, &mirror->rdev->flags) && - test_bit(R1BIO_FailFast, &r1_bio->state)) - read_bio->bi_opf |= MD_FAILFAST; - read_bio->bi_private = r1_bio; - - if (mddev->gendisk) - trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev), - read_bio, disk_devt(mddev->gendisk), - r1_bio->sector); - - if (max_sectors < r1_bio->sectors) { - /* could not read all from this device, so we will - * need another r1_bio. - */ - - sectors_handled = (r1_bio->sector + max_sectors - - bio->bi_iter.bi_sector); - r1_bio->sectors = max_sectors; - spin_lock_irq(&conf->device_lock); - if (bio->bi_phys_segments == 0) - bio->bi_phys_segments = 2; - else - bio->bi_phys_segments++; - spin_unlock_irq(&conf->device_lock); - /* Cannot call generic_make_request directly - * as that will be queued in __make_request - * and subsequent mempool_alloc might block waiting - * for it. So hand bio over to raid1d. - */ - reschedule_retry(r1_bio); - - r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); - - r1_bio->master_bio = bio; - r1_bio->sectors = bio_sectors(bio) - sectors_handled; - r1_bio->state = 0; - r1_bio->mddev = mddev; - r1_bio->sector = bio->bi_iter.bi_sector + - sectors_handled; - goto read_again; - } else - generic_make_request(read_bio); - return; - } - - /* - * WRITE: - */ if (conf->pending_count >= max_queued_requests) { md_wakeup_thread(mddev->thread); raid1_log(mddev, "wait queued"); @@ -1280,8 +1255,7 @@ static void raid1_make_request(struct mddev *mddev, struct bio * bio) int bad_sectors; int is_bad; - is_bad = is_badblock(rdev, r1_bio->sector, - max_sectors, + is_bad = is_badblock(rdev, r1_bio->sector, max_sectors, &first_bad, &bad_sectors); if (is_bad < 0) { /* mustn't write here until the bad block is @@ -1370,7 +1344,8 @@ static void raid1_make_request(struct mddev *mddev, struct bio * bio) continue; mbio = bio_clone_mddev(bio, GFP_NOIO, mddev); - bio_trim(mbio, r1_bio->sector - bio->bi_iter.bi_sector, max_sectors); + bio_trim(mbio, r1_bio->sector - bio->bi_iter.bi_sector, + max_sectors); if (first_clone) { /* do behind I/O ? @@ -1464,6 +1439,40 @@ static void raid1_make_request(struct mddev *mddev, struct bio * bio) wake_up(&conf->wait_barrier); } +static void raid1_make_request(struct mddev *mddev, struct bio *bio) +{ + struct r1conf *conf = mddev->private; + struct r1bio *r1_bio; + + /* + * make_request() can abort the operation when read-ahead is being + * used and no empty request is available. + * + */ + r1_bio = mempool_alloc(conf->r1bio_pool, GFP_NOIO); + + r1_bio->master_bio = bio; + r1_bio->sectors = bio_sectors(bio); + r1_bio->state = 0; + r1_bio->mddev = mddev; + r1_bio->sector = bio->bi_iter.bi_sector; + + /* We might need to issue multiple reads to different + * devices if there are bad blocks around, so we keep + * track of the number of reads in bio->bi_phys_segments. + * If this is 0, there is only one r1_bio and no locking + * will be needed when requests complete. If it is + * non-zero, then it is the number of not-completed requests. + */ + bio->bi_phys_segments = 0; + bio_clear_flag(bio, BIO_SEG_VALID); + + if (bio_data_dir(bio) == READ) + raid1_read_request(mddev, bio, r1_bio); + else + raid1_write_request(mddev, bio, r1_bio); +} + static void raid1_status(struct seq_file *seq, struct mddev *mddev) { struct r1conf *conf = mddev->private; -- 2.10.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] md/raid10: Refactor raid10_make_request 2016-12-05 20:02 [PATCH v3 0/2] Reorganize raid*_make_request to clean up code Robert LeBlanc 2016-12-05 20:02 ` [PATCH v3 1/2] md/raid1: Refactor raid1_make_request Robert LeBlanc @ 2016-12-05 20:02 ` Robert LeBlanc 2016-12-16 19:59 ` Shaohua Li 2016-12-05 20:04 ` [PATCH v3 0/2] Reorganize raid*_make_request to clean up code Robert LeBlanc 2 siblings, 1 reply; 6+ messages in thread From: Robert LeBlanc @ 2016-12-05 20:02 UTC (permalink / raw) To: linux-raid; +Cc: Robert LeBlanc Refactor raid10_make_request into seperate read and write functions to clean up the code. Signed-off-by: Robert LeBlanc <robert@leblancnet.us> --- drivers/md/raid10.c | 215 +++++++++++++++++++++++++++------------------------- 1 file changed, 111 insertions(+), 104 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 525ca99..8698e00 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1087,23 +1087,97 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) kfree(plug); } -static void __make_request(struct mddev *mddev, struct bio *bio) +static void raid10_read_request(struct mddev *mddev, struct bio *bio, + struct r10bio *r10_bio) { struct r10conf *conf = mddev->private; - struct r10bio *r10_bio; struct bio *read_bio; + const int op = bio_op(bio); + const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); + int sectors_handled; + int max_sectors; + struct md_rdev *rdev; + int slot; + + wait_barrier(conf); + +read_again: + rdev = read_balance(conf, r10_bio, &max_sectors); + if (!rdev) { + raid_end_bio_io(r10_bio); + return; + } + slot = r10_bio->read_slot; + + read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev); + bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector, + max_sectors); + + r10_bio->devs[slot].bio = read_bio; + r10_bio->devs[slot].rdev = rdev; + + read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr + + choose_data_offset(r10_bio, rdev); + read_bio->bi_bdev = rdev->bdev; + read_bio->bi_end_io = raid10_end_read_request; + bio_set_op_attrs(read_bio, op, do_sync); + if (test_bit(FailFast, &rdev->flags) && + test_bit(R10BIO_FailFast, &r10_bio->state)) + read_bio->bi_opf |= MD_FAILFAST; + read_bio->bi_private = r10_bio; + + if (mddev->gendisk) + trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev), + read_bio, disk_devt(mddev->gendisk), + r10_bio->sector); + if (max_sectors < r10_bio->sectors) { + /* Could not read all from this device, so we will + * need another r10_bio. + */ + sectors_handled = (r10_bio->sector + max_sectors + - bio->bi_iter.bi_sector); + r10_bio->sectors = max_sectors; + spin_lock_irq(&conf->device_lock); + if (bio->bi_phys_segments == 0) + bio->bi_phys_segments = 2; + else + bio->bi_phys_segments++; + spin_unlock_irq(&conf->device_lock); + /* Cannot call generic_make_request directly + * as that will be queued in __generic_make_request + * and subsequent mempool_alloc might block + * waiting for it. so hand bio over to raid10d. + */ + reschedule_retry(r10_bio); + + r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); + + r10_bio->master_bio = bio; + r10_bio->sectors = bio_sectors(bio) - sectors_handled; + r10_bio->state = 0; + r10_bio->mddev = mddev; + r10_bio->sector = bio->bi_iter.bi_sector + sectors_handled; + goto read_again; + } else + generic_make_request(read_bio); + return; +} + +static void raid10_write_request(struct mddev *mddev, struct bio *bio, + struct r10bio *r10_bio) +{ + struct r10conf *conf = mddev->private; int i; const int op = bio_op(bio); - const int rw = bio_data_dir(bio); const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); const unsigned long do_fua = (bio->bi_opf & REQ_FUA); unsigned long flags; struct md_rdev *blocked_rdev; struct blk_plug_cb *cb; struct raid10_plug_cb *plug = NULL; + sector_t sectors; int sectors_handled; int max_sectors; - int sectors; md_write_start(mddev, bio); @@ -1130,7 +1204,6 @@ static void __make_request(struct mddev *mddev, struct bio *bio) wait_barrier(conf); } if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && - bio_data_dir(bio) == WRITE && (mddev->reshape_backwards ? (bio->bi_iter.bi_sector < conf->reshape_safe && bio->bi_iter.bi_sector + sectors > conf->reshape_progress) @@ -1147,99 +1220,6 @@ static void __make_request(struct mddev *mddev, struct bio *bio) conf->reshape_safe = mddev->reshape_position; } - - r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); - - r10_bio->master_bio = bio; - r10_bio->sectors = sectors; - - r10_bio->mddev = mddev; - r10_bio->sector = bio->bi_iter.bi_sector; - r10_bio->state = 0; - - /* We might need to issue multiple reads to different - * devices if there are bad blocks around, so we keep - * track of the number of reads in bio->bi_phys_segments. - * If this is 0, there is only one r10_bio and no locking - * will be needed when the request completes. If it is - * non-zero, then it is the number of not-completed requests. - */ - bio->bi_phys_segments = 0; - bio_clear_flag(bio, BIO_SEG_VALID); - - if (rw == READ) { - /* - * read balancing logic: - */ - struct md_rdev *rdev; - int slot; - -read_again: - rdev = read_balance(conf, r10_bio, &max_sectors); - if (!rdev) { - raid_end_bio_io(r10_bio); - return; - } - slot = r10_bio->read_slot; - - read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev); - bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector, - max_sectors); - - r10_bio->devs[slot].bio = read_bio; - r10_bio->devs[slot].rdev = rdev; - - read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr + - choose_data_offset(r10_bio, rdev); - read_bio->bi_bdev = rdev->bdev; - read_bio->bi_end_io = raid10_end_read_request; - bio_set_op_attrs(read_bio, op, do_sync); - if (test_bit(FailFast, &rdev->flags) && - test_bit(R10BIO_FailFast, &r10_bio->state)) - read_bio->bi_opf |= MD_FAILFAST; - read_bio->bi_private = r10_bio; - - if (mddev->gendisk) - trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev), - read_bio, disk_devt(mddev->gendisk), - r10_bio->sector); - if (max_sectors < r10_bio->sectors) { - /* Could not read all from this device, so we will - * need another r10_bio. - */ - sectors_handled = (r10_bio->sector + max_sectors - - bio->bi_iter.bi_sector); - r10_bio->sectors = max_sectors; - spin_lock_irq(&conf->device_lock); - if (bio->bi_phys_segments == 0) - bio->bi_phys_segments = 2; - else - bio->bi_phys_segments++; - spin_unlock_irq(&conf->device_lock); - /* Cannot call generic_make_request directly - * as that will be queued in __generic_make_request - * and subsequent mempool_alloc might block - * waiting for it. so hand bio over to raid10d. - */ - reschedule_retry(r10_bio); - - r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); - - r10_bio->master_bio = bio; - r10_bio->sectors = bio_sectors(bio) - sectors_handled; - r10_bio->state = 0; - r10_bio->mddev = mddev; - r10_bio->sector = bio->bi_iter.bi_sector + - sectors_handled; - goto read_again; - } else - generic_make_request(read_bio); - return; - } - - /* - * WRITE: - */ if (conf->pending_count >= max_queued_requests) { md_wakeup_thread(mddev->thread); raid10_log(mddev, "wait queued"); @@ -1300,8 +1280,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) int bad_sectors; int is_bad; - is_bad = is_badblock(rdev, dev_sector, - max_sectors, + is_bad = is_badblock(rdev, dev_sector, max_sectors, &first_bad, &bad_sectors); if (is_bad < 0) { /* Mustn't write here until the bad block @@ -1405,8 +1384,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) r10_bio->devs[i].bio = mbio; mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+ - choose_data_offset(r10_bio, - rdev)); + choose_data_offset(r10_bio, rdev)); mbio->bi_bdev = rdev->bdev; mbio->bi_end_io = raid10_end_write_request; bio_set_op_attrs(mbio, op, do_sync | do_fua); @@ -1457,8 +1435,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) r10_bio->devs[i].repl_bio = mbio; mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr + - choose_data_offset( - r10_bio, rdev)); + choose_data_offset(r10_bio, rdev)); mbio->bi_bdev = rdev->bdev; mbio->bi_end_io = raid10_end_write_request; bio_set_op_attrs(mbio, op, do_sync | do_fua); @@ -1503,6 +1480,36 @@ static void __make_request(struct mddev *mddev, struct bio *bio) one_write_done(r10_bio); } +static void __make_request(struct mddev *mddev, struct bio *bio) +{ + struct r10conf *conf = mddev->private; + struct r10bio *r10_bio; + + r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); + + r10_bio->master_bio = bio; + r10_bio->sectors = bio_sectors(bio); + + r10_bio->mddev = mddev; + r10_bio->sector = bio->bi_iter.bi_sector; + r10_bio->state = 0; + + /* We might need to issue multiple reads to different + * devices if there are bad blocks around, so we keep + * track of the number of reads in bio->bi_phys_segments. + * If this is 0, there is only one r10_bio and no locking + * will be needed when the request completes. If it is + * non-zero, then it is the number of not-completed requests. + */ + bio->bi_phys_segments = 0; + bio_clear_flag(bio, BIO_SEG_VALID); + + if (bio_data_dir(bio) == READ) + raid10_read_request(mddev, bio, r10_bio); + else + raid10_write_request(mddev, bio, r10_bio); +} + static void raid10_make_request(struct mddev *mddev, struct bio *bio) { struct r10conf *conf = mddev->private; -- 2.10.2 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 2/2] md/raid10: Refactor raid10_make_request 2016-12-05 20:02 ` [PATCH v3 2/2] md/raid10: Refactor raid10_make_request Robert LeBlanc @ 2016-12-16 19:59 ` Shaohua Li 2016-12-16 20:49 ` Robert LeBlanc 0 siblings, 1 reply; 6+ messages in thread From: Shaohua Li @ 2016-12-16 19:59 UTC (permalink / raw) To: Robert LeBlanc; +Cc: linux-raid On Mon, Dec 05, 2016 at 01:02:58PM -0700, Robert LeBlanc wrote: > Refactor raid10_make_request into seperate read and write functions to > clean up the code. Merged the two patches, thanks! For this one, you deleted the recovery check for read path, I added it back. Please double check if the merged patch is good. The cleanup is supposed to not change behavior, so next time if you change something (like the recovery check), please do mention. Thanks, Shaohua > Signed-off-by: Robert LeBlanc <robert@leblancnet.us> > --- > drivers/md/raid10.c | 215 +++++++++++++++++++++++++++------------------------- > 1 file changed, 111 insertions(+), 104 deletions(-) > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index 525ca99..8698e00 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -1087,23 +1087,97 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) > kfree(plug); > } > > -static void __make_request(struct mddev *mddev, struct bio *bio) > +static void raid10_read_request(struct mddev *mddev, struct bio *bio, > + struct r10bio *r10_bio) > { > struct r10conf *conf = mddev->private; > - struct r10bio *r10_bio; > struct bio *read_bio; > + const int op = bio_op(bio); > + const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); > + int sectors_handled; > + int max_sectors; > + struct md_rdev *rdev; > + int slot; > + > + wait_barrier(conf); > + > +read_again: > + rdev = read_balance(conf, r10_bio, &max_sectors); > + if (!rdev) { > + raid_end_bio_io(r10_bio); > + return; > + } > + slot = r10_bio->read_slot; > + > + read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev); > + bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector, > + max_sectors); > + > + r10_bio->devs[slot].bio = read_bio; > + r10_bio->devs[slot].rdev = rdev; > + > + read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr + > + choose_data_offset(r10_bio, rdev); > + read_bio->bi_bdev = rdev->bdev; > + read_bio->bi_end_io = raid10_end_read_request; > + bio_set_op_attrs(read_bio, op, do_sync); > + if (test_bit(FailFast, &rdev->flags) && > + test_bit(R10BIO_FailFast, &r10_bio->state)) > + read_bio->bi_opf |= MD_FAILFAST; > + read_bio->bi_private = r10_bio; > + > + if (mddev->gendisk) > + trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev), > + read_bio, disk_devt(mddev->gendisk), > + r10_bio->sector); > + if (max_sectors < r10_bio->sectors) { > + /* Could not read all from this device, so we will > + * need another r10_bio. > + */ > + sectors_handled = (r10_bio->sector + max_sectors > + - bio->bi_iter.bi_sector); > + r10_bio->sectors = max_sectors; > + spin_lock_irq(&conf->device_lock); > + if (bio->bi_phys_segments == 0) > + bio->bi_phys_segments = 2; > + else > + bio->bi_phys_segments++; > + spin_unlock_irq(&conf->device_lock); > + /* Cannot call generic_make_request directly > + * as that will be queued in __generic_make_request > + * and subsequent mempool_alloc might block > + * waiting for it. so hand bio over to raid10d. > + */ > + reschedule_retry(r10_bio); > + > + r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); > + > + r10_bio->master_bio = bio; > + r10_bio->sectors = bio_sectors(bio) - sectors_handled; > + r10_bio->state = 0; > + r10_bio->mddev = mddev; > + r10_bio->sector = bio->bi_iter.bi_sector + sectors_handled; > + goto read_again; > + } else > + generic_make_request(read_bio); > + return; > +} > + > +static void raid10_write_request(struct mddev *mddev, struct bio *bio, > + struct r10bio *r10_bio) > +{ > + struct r10conf *conf = mddev->private; > int i; > const int op = bio_op(bio); > - const int rw = bio_data_dir(bio); > const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); > const unsigned long do_fua = (bio->bi_opf & REQ_FUA); > unsigned long flags; > struct md_rdev *blocked_rdev; > struct blk_plug_cb *cb; > struct raid10_plug_cb *plug = NULL; > + sector_t sectors; > int sectors_handled; > int max_sectors; > - int sectors; > > md_write_start(mddev, bio); > > @@ -1130,7 +1204,6 @@ static void __make_request(struct mddev *mddev, struct bio *bio) > wait_barrier(conf); > } > if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && > - bio_data_dir(bio) == WRITE && > (mddev->reshape_backwards > ? (bio->bi_iter.bi_sector < conf->reshape_safe && > bio->bi_iter.bi_sector + sectors > conf->reshape_progress) > @@ -1147,99 +1220,6 @@ static void __make_request(struct mddev *mddev, struct bio *bio) > > conf->reshape_safe = mddev->reshape_position; > } > - > - r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); > - > - r10_bio->master_bio = bio; > - r10_bio->sectors = sectors; > - > - r10_bio->mddev = mddev; > - r10_bio->sector = bio->bi_iter.bi_sector; > - r10_bio->state = 0; > - > - /* We might need to issue multiple reads to different > - * devices if there are bad blocks around, so we keep > - * track of the number of reads in bio->bi_phys_segments. > - * If this is 0, there is only one r10_bio and no locking > - * will be needed when the request completes. If it is > - * non-zero, then it is the number of not-completed requests. > - */ > - bio->bi_phys_segments = 0; > - bio_clear_flag(bio, BIO_SEG_VALID); > - > - if (rw == READ) { > - /* > - * read balancing logic: > - */ > - struct md_rdev *rdev; > - int slot; > - > -read_again: > - rdev = read_balance(conf, r10_bio, &max_sectors); > - if (!rdev) { > - raid_end_bio_io(r10_bio); > - return; > - } > - slot = r10_bio->read_slot; > - > - read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev); > - bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector, > - max_sectors); > - > - r10_bio->devs[slot].bio = read_bio; > - r10_bio->devs[slot].rdev = rdev; > - > - read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr + > - choose_data_offset(r10_bio, rdev); > - read_bio->bi_bdev = rdev->bdev; > - read_bio->bi_end_io = raid10_end_read_request; > - bio_set_op_attrs(read_bio, op, do_sync); > - if (test_bit(FailFast, &rdev->flags) && > - test_bit(R10BIO_FailFast, &r10_bio->state)) > - read_bio->bi_opf |= MD_FAILFAST; > - read_bio->bi_private = r10_bio; > - > - if (mddev->gendisk) > - trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev), > - read_bio, disk_devt(mddev->gendisk), > - r10_bio->sector); > - if (max_sectors < r10_bio->sectors) { > - /* Could not read all from this device, so we will > - * need another r10_bio. > - */ > - sectors_handled = (r10_bio->sector + max_sectors > - - bio->bi_iter.bi_sector); > - r10_bio->sectors = max_sectors; > - spin_lock_irq(&conf->device_lock); > - if (bio->bi_phys_segments == 0) > - bio->bi_phys_segments = 2; > - else > - bio->bi_phys_segments++; > - spin_unlock_irq(&conf->device_lock); > - /* Cannot call generic_make_request directly > - * as that will be queued in __generic_make_request > - * and subsequent mempool_alloc might block > - * waiting for it. so hand bio over to raid10d. > - */ > - reschedule_retry(r10_bio); > - > - r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); > - > - r10_bio->master_bio = bio; > - r10_bio->sectors = bio_sectors(bio) - sectors_handled; > - r10_bio->state = 0; > - r10_bio->mddev = mddev; > - r10_bio->sector = bio->bi_iter.bi_sector + > - sectors_handled; > - goto read_again; > - } else > - generic_make_request(read_bio); > - return; > - } > - > - /* > - * WRITE: > - */ > if (conf->pending_count >= max_queued_requests) { > md_wakeup_thread(mddev->thread); > raid10_log(mddev, "wait queued"); > @@ -1300,8 +1280,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) > int bad_sectors; > int is_bad; > > - is_bad = is_badblock(rdev, dev_sector, > - max_sectors, > + is_bad = is_badblock(rdev, dev_sector, max_sectors, > &first_bad, &bad_sectors); > if (is_bad < 0) { > /* Mustn't write here until the bad block > @@ -1405,8 +1384,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) > r10_bio->devs[i].bio = mbio; > > mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+ > - choose_data_offset(r10_bio, > - rdev)); > + choose_data_offset(r10_bio, rdev)); > mbio->bi_bdev = rdev->bdev; > mbio->bi_end_io = raid10_end_write_request; > bio_set_op_attrs(mbio, op, do_sync | do_fua); > @@ -1457,8 +1435,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) > r10_bio->devs[i].repl_bio = mbio; > > mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr + > - choose_data_offset( > - r10_bio, rdev)); > + choose_data_offset(r10_bio, rdev)); > mbio->bi_bdev = rdev->bdev; > mbio->bi_end_io = raid10_end_write_request; > bio_set_op_attrs(mbio, op, do_sync | do_fua); > @@ -1503,6 +1480,36 @@ static void __make_request(struct mddev *mddev, struct bio *bio) > one_write_done(r10_bio); > } > > +static void __make_request(struct mddev *mddev, struct bio *bio) > +{ > + struct r10conf *conf = mddev->private; > + struct r10bio *r10_bio; > + > + r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); > + > + r10_bio->master_bio = bio; > + r10_bio->sectors = bio_sectors(bio); > + > + r10_bio->mddev = mddev; > + r10_bio->sector = bio->bi_iter.bi_sector; > + r10_bio->state = 0; > + > + /* We might need to issue multiple reads to different > + * devices if there are bad blocks around, so we keep > + * track of the number of reads in bio->bi_phys_segments. > + * If this is 0, there is only one r10_bio and no locking > + * will be needed when the request completes. If it is > + * non-zero, then it is the number of not-completed requests. > + */ > + bio->bi_phys_segments = 0; > + bio_clear_flag(bio, BIO_SEG_VALID); > + > + if (bio_data_dir(bio) == READ) > + raid10_read_request(mddev, bio, r10_bio); > + else > + raid10_write_request(mddev, bio, r10_bio); > +} > + > static void raid10_make_request(struct mddev *mddev, struct bio *bio) > { > struct r10conf *conf = mddev->private; > -- > 2.10.2 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-raid" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 2/2] md/raid10: Refactor raid10_make_request 2016-12-16 19:59 ` Shaohua Li @ 2016-12-16 20:49 ` Robert LeBlanc 0 siblings, 0 replies; 6+ messages in thread From: Robert LeBlanc @ 2016-12-16 20:49 UTC (permalink / raw) To: Shaohua Li; +Cc: linux-raid Thank you for the feedback. It looked like read_balance already checked for recovery and so I removed it from the read path here. I didn't think it needed a comment. I'll be more complete next time. ---------------- Robert LeBlanc PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1 On Fri, Dec 16, 2016 at 12:59 PM, Shaohua Li <shli@kernel.org> wrote: > On Mon, Dec 05, 2016 at 01:02:58PM -0700, Robert LeBlanc wrote: >> Refactor raid10_make_request into seperate read and write functions to >> clean up the code. > > Merged the two patches, thanks! > > For this one, you deleted the recovery check for read path, I added it back. > Please double check if the merged patch is good. The cleanup is supposed to not > change behavior, so next time if you change something (like the recovery > check), please do mention. > > Thanks, > Shaohua > > >> Signed-off-by: Robert LeBlanc <robert@leblancnet.us> >> --- >> drivers/md/raid10.c | 215 +++++++++++++++++++++++++++------------------------- >> 1 file changed, 111 insertions(+), 104 deletions(-) >> >> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c >> index 525ca99..8698e00 100644 >> --- a/drivers/md/raid10.c >> +++ b/drivers/md/raid10.c >> @@ -1087,23 +1087,97 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) >> kfree(plug); >> } >> >> -static void __make_request(struct mddev *mddev, struct bio *bio) >> +static void raid10_read_request(struct mddev *mddev, struct bio *bio, >> + struct r10bio *r10_bio) >> { >> struct r10conf *conf = mddev->private; >> - struct r10bio *r10_bio; >> struct bio *read_bio; >> + const int op = bio_op(bio); >> + const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); >> + int sectors_handled; >> + int max_sectors; >> + struct md_rdev *rdev; >> + int slot; >> + >> + wait_barrier(conf); >> + >> +read_again: >> + rdev = read_balance(conf, r10_bio, &max_sectors); >> + if (!rdev) { >> + raid_end_bio_io(r10_bio); >> + return; >> + } >> + slot = r10_bio->read_slot; >> + >> + read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev); >> + bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector, >> + max_sectors); >> + >> + r10_bio->devs[slot].bio = read_bio; >> + r10_bio->devs[slot].rdev = rdev; >> + >> + read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr + >> + choose_data_offset(r10_bio, rdev); >> + read_bio->bi_bdev = rdev->bdev; >> + read_bio->bi_end_io = raid10_end_read_request; >> + bio_set_op_attrs(read_bio, op, do_sync); >> + if (test_bit(FailFast, &rdev->flags) && >> + test_bit(R10BIO_FailFast, &r10_bio->state)) >> + read_bio->bi_opf |= MD_FAILFAST; >> + read_bio->bi_private = r10_bio; >> + >> + if (mddev->gendisk) >> + trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev), >> + read_bio, disk_devt(mddev->gendisk), >> + r10_bio->sector); >> + if (max_sectors < r10_bio->sectors) { >> + /* Could not read all from this device, so we will >> + * need another r10_bio. >> + */ >> + sectors_handled = (r10_bio->sector + max_sectors >> + - bio->bi_iter.bi_sector); >> + r10_bio->sectors = max_sectors; >> + spin_lock_irq(&conf->device_lock); >> + if (bio->bi_phys_segments == 0) >> + bio->bi_phys_segments = 2; >> + else >> + bio->bi_phys_segments++; >> + spin_unlock_irq(&conf->device_lock); >> + /* Cannot call generic_make_request directly >> + * as that will be queued in __generic_make_request >> + * and subsequent mempool_alloc might block >> + * waiting for it. so hand bio over to raid10d. >> + */ >> + reschedule_retry(r10_bio); >> + >> + r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); >> + >> + r10_bio->master_bio = bio; >> + r10_bio->sectors = bio_sectors(bio) - sectors_handled; >> + r10_bio->state = 0; >> + r10_bio->mddev = mddev; >> + r10_bio->sector = bio->bi_iter.bi_sector + sectors_handled; >> + goto read_again; >> + } else >> + generic_make_request(read_bio); >> + return; >> +} >> + >> +static void raid10_write_request(struct mddev *mddev, struct bio *bio, >> + struct r10bio *r10_bio) >> +{ >> + struct r10conf *conf = mddev->private; >> int i; >> const int op = bio_op(bio); >> - const int rw = bio_data_dir(bio); >> const unsigned long do_sync = (bio->bi_opf & REQ_SYNC); >> const unsigned long do_fua = (bio->bi_opf & REQ_FUA); >> unsigned long flags; >> struct md_rdev *blocked_rdev; >> struct blk_plug_cb *cb; >> struct raid10_plug_cb *plug = NULL; >> + sector_t sectors; >> int sectors_handled; >> int max_sectors; >> - int sectors; >> >> md_write_start(mddev, bio); >> >> @@ -1130,7 +1204,6 @@ static void __make_request(struct mddev *mddev, struct bio *bio) >> wait_barrier(conf); >> } >> if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && >> - bio_data_dir(bio) == WRITE && >> (mddev->reshape_backwards >> ? (bio->bi_iter.bi_sector < conf->reshape_safe && >> bio->bi_iter.bi_sector + sectors > conf->reshape_progress) >> @@ -1147,99 +1220,6 @@ static void __make_request(struct mddev *mddev, struct bio *bio) >> >> conf->reshape_safe = mddev->reshape_position; >> } >> - >> - r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); >> - >> - r10_bio->master_bio = bio; >> - r10_bio->sectors = sectors; >> - >> - r10_bio->mddev = mddev; >> - r10_bio->sector = bio->bi_iter.bi_sector; >> - r10_bio->state = 0; >> - >> - /* We might need to issue multiple reads to different >> - * devices if there are bad blocks around, so we keep >> - * track of the number of reads in bio->bi_phys_segments. >> - * If this is 0, there is only one r10_bio and no locking >> - * will be needed when the request completes. If it is >> - * non-zero, then it is the number of not-completed requests. >> - */ >> - bio->bi_phys_segments = 0; >> - bio_clear_flag(bio, BIO_SEG_VALID); >> - >> - if (rw == READ) { >> - /* >> - * read balancing logic: >> - */ >> - struct md_rdev *rdev; >> - int slot; >> - >> -read_again: >> - rdev = read_balance(conf, r10_bio, &max_sectors); >> - if (!rdev) { >> - raid_end_bio_io(r10_bio); >> - return; >> - } >> - slot = r10_bio->read_slot; >> - >> - read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev); >> - bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector, >> - max_sectors); >> - >> - r10_bio->devs[slot].bio = read_bio; >> - r10_bio->devs[slot].rdev = rdev; >> - >> - read_bio->bi_iter.bi_sector = r10_bio->devs[slot].addr + >> - choose_data_offset(r10_bio, rdev); >> - read_bio->bi_bdev = rdev->bdev; >> - read_bio->bi_end_io = raid10_end_read_request; >> - bio_set_op_attrs(read_bio, op, do_sync); >> - if (test_bit(FailFast, &rdev->flags) && >> - test_bit(R10BIO_FailFast, &r10_bio->state)) >> - read_bio->bi_opf |= MD_FAILFAST; >> - read_bio->bi_private = r10_bio; >> - >> - if (mddev->gendisk) >> - trace_block_bio_remap(bdev_get_queue(read_bio->bi_bdev), >> - read_bio, disk_devt(mddev->gendisk), >> - r10_bio->sector); >> - if (max_sectors < r10_bio->sectors) { >> - /* Could not read all from this device, so we will >> - * need another r10_bio. >> - */ >> - sectors_handled = (r10_bio->sector + max_sectors >> - - bio->bi_iter.bi_sector); >> - r10_bio->sectors = max_sectors; >> - spin_lock_irq(&conf->device_lock); >> - if (bio->bi_phys_segments == 0) >> - bio->bi_phys_segments = 2; >> - else >> - bio->bi_phys_segments++; >> - spin_unlock_irq(&conf->device_lock); >> - /* Cannot call generic_make_request directly >> - * as that will be queued in __generic_make_request >> - * and subsequent mempool_alloc might block >> - * waiting for it. so hand bio over to raid10d. >> - */ >> - reschedule_retry(r10_bio); >> - >> - r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); >> - >> - r10_bio->master_bio = bio; >> - r10_bio->sectors = bio_sectors(bio) - sectors_handled; >> - r10_bio->state = 0; >> - r10_bio->mddev = mddev; >> - r10_bio->sector = bio->bi_iter.bi_sector + >> - sectors_handled; >> - goto read_again; >> - } else >> - generic_make_request(read_bio); >> - return; >> - } >> - >> - /* >> - * WRITE: >> - */ >> if (conf->pending_count >= max_queued_requests) { >> md_wakeup_thread(mddev->thread); >> raid10_log(mddev, "wait queued"); >> @@ -1300,8 +1280,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) >> int bad_sectors; >> int is_bad; >> >> - is_bad = is_badblock(rdev, dev_sector, >> - max_sectors, >> + is_bad = is_badblock(rdev, dev_sector, max_sectors, >> &first_bad, &bad_sectors); >> if (is_bad < 0) { >> /* Mustn't write here until the bad block >> @@ -1405,8 +1384,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) >> r10_bio->devs[i].bio = mbio; >> >> mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr+ >> - choose_data_offset(r10_bio, >> - rdev)); >> + choose_data_offset(r10_bio, rdev)); >> mbio->bi_bdev = rdev->bdev; >> mbio->bi_end_io = raid10_end_write_request; >> bio_set_op_attrs(mbio, op, do_sync | do_fua); >> @@ -1457,8 +1435,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio) >> r10_bio->devs[i].repl_bio = mbio; >> >> mbio->bi_iter.bi_sector = (r10_bio->devs[i].addr + >> - choose_data_offset( >> - r10_bio, rdev)); >> + choose_data_offset(r10_bio, rdev)); >> mbio->bi_bdev = rdev->bdev; >> mbio->bi_end_io = raid10_end_write_request; >> bio_set_op_attrs(mbio, op, do_sync | do_fua); >> @@ -1503,6 +1480,36 @@ static void __make_request(struct mddev *mddev, struct bio *bio) >> one_write_done(r10_bio); >> } >> >> +static void __make_request(struct mddev *mddev, struct bio *bio) >> +{ >> + struct r10conf *conf = mddev->private; >> + struct r10bio *r10_bio; >> + >> + r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); >> + >> + r10_bio->master_bio = bio; >> + r10_bio->sectors = bio_sectors(bio); >> + >> + r10_bio->mddev = mddev; >> + r10_bio->sector = bio->bi_iter.bi_sector; >> + r10_bio->state = 0; >> + >> + /* We might need to issue multiple reads to different >> + * devices if there are bad blocks around, so we keep >> + * track of the number of reads in bio->bi_phys_segments. >> + * If this is 0, there is only one r10_bio and no locking >> + * will be needed when the request completes. If it is >> + * non-zero, then it is the number of not-completed requests. >> + */ >> + bio->bi_phys_segments = 0; >> + bio_clear_flag(bio, BIO_SEG_VALID); >> + >> + if (bio_data_dir(bio) == READ) >> + raid10_read_request(mddev, bio, r10_bio); >> + else >> + raid10_write_request(mddev, bio, r10_bio); >> +} >> + >> static void raid10_make_request(struct mddev *mddev, struct bio *bio) >> { >> struct r10conf *conf = mddev->private; >> -- >> 2.10.2 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-raid" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] Reorganize raid*_make_request to clean up code 2016-12-05 20:02 [PATCH v3 0/2] Reorganize raid*_make_request to clean up code Robert LeBlanc 2016-12-05 20:02 ` [PATCH v3 1/2] md/raid1: Refactor raid1_make_request Robert LeBlanc 2016-12-05 20:02 ` [PATCH v3 2/2] md/raid10: Refactor raid10_make_request Robert LeBlanc @ 2016-12-05 20:04 ` Robert LeBlanc 2 siblings, 0 replies; 6+ messages in thread From: Robert LeBlanc @ 2016-12-05 20:04 UTC (permalink / raw) To: linux-raid; +Cc: Robert LeBlanc And also rebased against for-next. ---------------- Robert LeBlanc PGP Fingerprint 79A2 9CA4 6CC4 45DD A904 C70E E654 3BB2 FA62 B9F1 On Mon, Dec 5, 2016 at 1:02 PM, Robert LeBlanc <robert@leblancnet.us> wrote: > In response to Christoph, I've broken the read and writes into their own > functions to make the code even cleaner. Since it is such a big change, I broke > up the commits into this series instead of creating a v2 of the previous patch. > > Changes since v2: > Shaohua Li > * Make md_write_start before wait_barrier > * Move I/O in recovery stripe test to write path > * Changed to if/then instead of return in __make_request > > Changes since v1: > > John Stoffel > * Changed to if/then instead of return in raid1_make_request > > Neil Brown > * Moved wait_barrier into raid1_{read,write}_request so that it could be after > ->suspend_{hi,lo}. This prevents a write blocking a resync until the suspend > region is moved. > > Robert LeBlanc (2): > md/raid1: Refactor raid1_make_request > md/raid10: Refactor raid10_make_request > > drivers/md/raid1.c | 259 +++++++++++++++++++++++++++------------------------- > drivers/md/raid10.c | 215 ++++++++++++++++++++++--------------------- > 2 files changed, 245 insertions(+), 229 deletions(-) > > -- > 2.10.2 > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-12-16 20:49 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-12-05 20:02 [PATCH v3 0/2] Reorganize raid*_make_request to clean up code Robert LeBlanc 2016-12-05 20:02 ` [PATCH v3 1/2] md/raid1: Refactor raid1_make_request Robert LeBlanc 2016-12-05 20:02 ` [PATCH v3 2/2] md/raid10: Refactor raid10_make_request Robert LeBlanc 2016-12-16 19:59 ` Shaohua Li 2016-12-16 20:49 ` Robert LeBlanc 2016-12-05 20:04 ` [PATCH v3 0/2] Reorganize raid*_make_request to clean up code Robert LeBlanc
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox