summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-01-20 03:12:00 -0800
committerLinus Torvalds <torvalds@home.osdl.org>2004-01-20 03:12:00 -0800
commit5edef83d7b0863390315df4d4e0cf9a3d805c844 (patch)
treeddb21f077a0db1bbc3d2bacbf0bd49de7fe85469
parent0b3e92bc78ff45b75bf9a7edc76d9fc76e1d1cb2 (diff)
[PATCH] md: Don't allow raid5 rebuild to swamp raid5 stripe cache
From: NeilBrown <neilb@cse.unsw.edu.au> raid5 rebuild takes stripes so agressively that other access cannot get a look-in. With this patch, the rebuild pauses slightly if there is a shortage of stripes to let other processes have a chance. akpm: I was worried about starvation due to the harsh semantics of yield() in 2.6. But Neil has performed specific testing for that and things seem OK. If people do note CPU starvation problems we will need to replace the yield() with a schedule_timeout(1).
-rw-r--r--drivers/md/raid5.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index def75ad21669..3adb76cdd629 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1395,7 +1395,14 @@ static int sync_request (mddev_t *mddev, sector_t sector_nr, int go_faster)
first_sector = raid5_compute_sector(stripe*data_disks*sectors_per_chunk
+ chunk_offset, raid_disks, data_disks, &dd_idx, &pd_idx, conf);
- sh = get_active_stripe(conf, sector_nr, pd_idx, 0);
+ sh = get_active_stripe(conf, sector_nr, pd_idx, 1);
+ if (sh == NULL) {
+ sh = get_active_stripe(conf, sector_nr, pd_idx, 0);
+ /* make sure we don't swamp the stripe cache if someone else
+ * is trying to get access
+ */
+ yield();
+ }
spin_lock(&sh->lock);
set_bit(STRIPE_SYNCING, &sh->state);
clear_bit(STRIPE_INSYNC, &sh->state);