diff options
author | NeilBrown <neilb@suse.de> | 2011-04-18 04:25:43 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-04-18 04:25:43 -0400 |
commit | 7c13edc87510f665da3094174e1fd633e06649f4 (patch) | |
tree | c0c50ab6ac43e9c762199bfd94c787f43a8e0896 /drivers/md | |
parent | 97658cdd3af7d01461874c93b89afa4a2465e7c6 (diff) |
md: incorporate new plugging into raid5.
In raid5 plugging is used for 2 things:
1/ collecting writes that require a bitmap update
2/ collecting writes in the hope that we can create full
stripes - or at least more-full.
We now release these different sets of stripes when plug_cnt
is zero.
Also in make_request, we call mddev_check_plug to hopefully increase
plug_cnt, and wake up the thread at the end if plugging wasn't
achieved for some reason.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/raid5.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index a1755a6a3e5f..f301e6ae220c 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -27,12 +27,12 @@ | |||
27 | * | 27 | * |
28 | * We group bitmap updates into batches. Each batch has a number. | 28 | * We group bitmap updates into batches. Each batch has a number. |
29 | * We may write out several batches at once, but that isn't very important. | 29 | * We may write out several batches at once, but that isn't very important. |
30 | * conf->bm_write is the number of the last batch successfully written. | 30 | * conf->seq_write is the number of the last batch successfully written. |
31 | * conf->bm_flush is the number of the last batch that was closed to | 31 | * conf->seq_flush is the number of the last batch that was closed to |
32 | * new additions. | 32 | * new additions. |
33 | * When we discover that we will need to write to any block in a stripe | 33 | * When we discover that we will need to write to any block in a stripe |
34 | * (in add_stripe_bio) we update the in-memory bitmap and record in sh->bm_seq | 34 | * (in add_stripe_bio) we update the in-memory bitmap and record in sh->bm_seq |
35 | * the number of the batch it will be in. This is bm_flush+1. | 35 | * the number of the batch it will be in. This is seq_flush+1. |
36 | * When we are ready to do a write, if that batch hasn't been written yet, | 36 | * When we are ready to do a write, if that batch hasn't been written yet, |
37 | * we plug the array and queue the stripe for later. | 37 | * we plug the array and queue the stripe for later. |
38 | * When an unplug happens, we increment bm_flush, thus closing the current | 38 | * When an unplug happens, we increment bm_flush, thus closing the current |
@@ -459,7 +459,7 @@ get_active_stripe(raid5_conf_t *conf, sector_t sector, | |||
459 | < (conf->max_nr_stripes *3/4) | 459 | < (conf->max_nr_stripes *3/4) |
460 | || !conf->inactive_blocked), | 460 | || !conf->inactive_blocked), |
461 | conf->device_lock, | 461 | conf->device_lock, |
462 | md_wakeup_thread(conf->mddev->thread)); | 462 | ); |
463 | conf->inactive_blocked = 0; | 463 | conf->inactive_blocked = 0; |
464 | } else | 464 | } else |
465 | init_stripe(sh, sector, previous); | 465 | init_stripe(sh, sector, previous); |
@@ -3927,6 +3927,7 @@ static int make_request(mddev_t *mddev, struct bio * bi) | |||
3927 | struct stripe_head *sh; | 3927 | struct stripe_head *sh; |
3928 | const int rw = bio_data_dir(bi); | 3928 | const int rw = bio_data_dir(bi); |
3929 | int remaining; | 3929 | int remaining; |
3930 | int plugged; | ||
3930 | 3931 | ||
3931 | if (unlikely(bi->bi_rw & REQ_FLUSH)) { | 3932 | if (unlikely(bi->bi_rw & REQ_FLUSH)) { |
3932 | md_flush_request(mddev, bi); | 3933 | md_flush_request(mddev, bi); |
@@ -3945,6 +3946,7 @@ static int make_request(mddev_t *mddev, struct bio * bi) | |||
3945 | bi->bi_next = NULL; | 3946 | bi->bi_next = NULL; |
3946 | bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ | 3947 | bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ |
3947 | 3948 | ||
3949 | plugged = mddev_check_plugged(mddev); | ||
3948 | for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { | 3950 | for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { |
3949 | DEFINE_WAIT(w); | 3951 | DEFINE_WAIT(w); |
3950 | int disks, data_disks; | 3952 | int disks, data_disks; |
@@ -4059,6 +4061,9 @@ static int make_request(mddev_t *mddev, struct bio * bi) | |||
4059 | } | 4061 | } |
4060 | 4062 | ||
4061 | } | 4063 | } |
4064 | if (!plugged) | ||
4065 | md_wakeup_thread(mddev->thread); | ||
4066 | |||
4062 | spin_lock_irq(&conf->device_lock); | 4067 | spin_lock_irq(&conf->device_lock); |
4063 | remaining = raid5_dec_bi_phys_segments(bi); | 4068 | remaining = raid5_dec_bi_phys_segments(bi); |
4064 | spin_unlock_irq(&conf->device_lock); | 4069 | spin_unlock_irq(&conf->device_lock); |
@@ -4472,14 +4477,18 @@ static void raid5d(mddev_t *mddev) | |||
4472 | while (1) { | 4477 | while (1) { |
4473 | struct bio *bio; | 4478 | struct bio *bio; |
4474 | 4479 | ||
4475 | if (conf->seq_flush != conf->seq_write) { | 4480 | if (atomic_read(&mddev->plug_cnt) == 0 && |
4476 | int seq = conf->seq_flush; | 4481 | !list_empty(&conf->bitmap_list)) { |
4482 | /* Now is a good time to flush some bitmap updates */ | ||
4483 | conf->seq_flush++; | ||
4477 | spin_unlock_irq(&conf->device_lock); | 4484 | spin_unlock_irq(&conf->device_lock); |
4478 | bitmap_unplug(mddev->bitmap); | 4485 | bitmap_unplug(mddev->bitmap); |
4479 | spin_lock_irq(&conf->device_lock); | 4486 | spin_lock_irq(&conf->device_lock); |
4480 | conf->seq_write = seq; | 4487 | conf->seq_write = conf->seq_flush; |
4481 | activate_bit_delay(conf); | 4488 | activate_bit_delay(conf); |
4482 | } | 4489 | } |
4490 | if (atomic_read(&mddev->plug_cnt) == 0) | ||
4491 | raid5_activate_delayed(conf); | ||
4483 | 4492 | ||
4484 | while ((bio = remove_bio_from_retry(conf))) { | 4493 | while ((bio = remove_bio_from_retry(conf))) { |
4485 | int ok; | 4494 | int ok; |