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>

NeilBrown 7c13edc8 97658cdd

+16 -7
+16 -7
drivers/md/raid5.c
··· 27 27 * 28 28 * We group bitmap updates into batches. Each batch has a number. 29 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. 31 - * conf->bm_flush is the number of the last batch that was closed to 30 + * conf->seq_write is the number of the last batch successfully written. 31 + * conf->seq_flush is the number of the last batch that was closed to 32 32 * new additions. 33 33 * When we discover that we will need to write to any block in a stripe 34 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 36 * When we are ready to do a write, if that batch hasn't been written yet, 37 37 * we plug the array and queue the stripe for later. 38 38 * When an unplug happens, we increment bm_flush, thus closing the current ··· 459 459 < (conf->max_nr_stripes *3/4) 460 460 || !conf->inactive_blocked), 461 461 conf->device_lock, 462 - md_wakeup_thread(conf->mddev->thread)); 462 + ); 463 463 conf->inactive_blocked = 0; 464 464 } else 465 465 init_stripe(sh, sector, previous); ··· 3927 3927 struct stripe_head *sh; 3928 3928 const int rw = bio_data_dir(bi); 3929 3929 int remaining; 3930 + int plugged; 3930 3931 3931 3932 if (unlikely(bi->bi_rw & REQ_FLUSH)) { 3932 3933 md_flush_request(mddev, bi); ··· 3946 3945 bi->bi_next = NULL; 3947 3946 bi->bi_phys_segments = 1; /* over-loaded to count active stripes */ 3948 3947 3948 + plugged = mddev_check_plugged(mddev); 3949 3949 for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) { 3950 3950 DEFINE_WAIT(w); 3951 3951 int disks, data_disks; ··· 4061 4059 } 4062 4060 4063 4061 } 4062 + if (!plugged) 4063 + md_wakeup_thread(mddev->thread); 4064 + 4064 4065 spin_lock_irq(&conf->device_lock); 4065 4066 remaining = raid5_dec_bi_phys_segments(bi); 4066 4067 spin_unlock_irq(&conf->device_lock); ··· 4477 4472 while (1) { 4478 4473 struct bio *bio; 4479 4474 4480 - if (conf->seq_flush != conf->seq_write) { 4481 - int seq = conf->seq_flush; 4475 + if (atomic_read(&mddev->plug_cnt) == 0 && 4476 + !list_empty(&conf->bitmap_list)) { 4477 + /* Now is a good time to flush some bitmap updates */ 4478 + conf->seq_flush++; 4482 4479 spin_unlock_irq(&conf->device_lock); 4483 4480 bitmap_unplug(mddev->bitmap); 4484 4481 spin_lock_irq(&conf->device_lock); 4485 - conf->seq_write = seq; 4482 + conf->seq_write = conf->seq_flush; 4486 4483 activate_bit_delay(conf); 4487 4484 } 4485 + if (atomic_read(&mddev->plug_cnt) == 0) 4486 + raid5_activate_delayed(conf); 4488 4487 4489 4488 while ((bio = remove_bio_from_retry(conf))) { 4490 4489 int ok;