aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShaohua Li <shli@kernel.org>2012-07-19 02:01:31 -0400
committerNeilBrown <neilb@suse.de>2012-07-19 02:01:31 -0400
commit7eaf7e8eb31747e4259d60288b44b194fb3d56c7 (patch)
treebd084366fa8b61fd1eec312b54d0e861a39fba18
parente7836bd6f60d659830b87804f7f4026edfe0f1d1 (diff)
raid5: remove unnecessary bitmap write optimization
Neil pointed out the bitmap write optimization in handle_stripe_clean_event() is unnecessary, because the chance one stripe gets written twice in the mean time is rare. We can always do a bitmap_startwrite when a write request is added to a stripe and bitmap_endwrite after write request is done. Delete the optimization. With it, we can delete some cases of device_lock. Signed-off-by: Shaohua Li <shli@fusionio.com> Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/raid5.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 6ef1eeb68f7..9ad452c6d7e 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2357,7 +2357,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
2357 spin_lock_irq(&conf->device_lock); 2357 spin_lock_irq(&conf->device_lock);
2358 if (forwrite) { 2358 if (forwrite) {
2359 bip = &sh->dev[dd_idx].towrite; 2359 bip = &sh->dev[dd_idx].towrite;
2360 if (*bip == NULL && sh->dev[dd_idx].written == NULL) 2360 if (*bip == NULL)
2361 firstwrite = 1; 2361 firstwrite = 1;
2362 } else 2362 } else
2363 bip = &sh->dev[dd_idx].toread; 2363 bip = &sh->dev[dd_idx].toread;
@@ -2458,6 +2458,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
2458 /* fail all writes first */ 2458 /* fail all writes first */
2459 bi = sh->dev[i].towrite; 2459 bi = sh->dev[i].towrite;
2460 sh->dev[i].towrite = NULL; 2460 sh->dev[i].towrite = NULL;
2461 spin_unlock_irq(&conf->device_lock);
2461 if (bi) { 2462 if (bi) {
2462 s->to_write--; 2463 s->to_write--;
2463 bitmap_end = 1; 2464 bitmap_end = 1;
@@ -2477,6 +2478,10 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
2477 } 2478 }
2478 bi = nextbi; 2479 bi = nextbi;
2479 } 2480 }
2481 if (bitmap_end)
2482 bitmap_endwrite(conf->mddev->bitmap, sh->sector,
2483 STRIPE_SECTORS, 0, 0);
2484 bitmap_end = 0;
2480 /* and fail all 'written' */ 2485 /* and fail all 'written' */
2481 bi = sh->dev[i].written; 2486 bi = sh->dev[i].written;
2482 sh->dev[i].written = NULL; 2487 sh->dev[i].written = NULL;
@@ -2516,7 +2521,6 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
2516 bi = nextbi; 2521 bi = nextbi;
2517 } 2522 }
2518 } 2523 }
2519 spin_unlock_irq(&conf->device_lock);
2520 if (bitmap_end) 2524 if (bitmap_end)
2521 bitmap_endwrite(conf->mddev->bitmap, sh->sector, 2525 bitmap_endwrite(conf->mddev->bitmap, sh->sector,
2522 STRIPE_SECTORS, 0, 0); 2526 STRIPE_SECTORS, 0, 0);
@@ -2720,9 +2724,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
2720 test_bit(R5_UPTODATE, &dev->flags)) { 2724 test_bit(R5_UPTODATE, &dev->flags)) {
2721 /* We can return any write requests */ 2725 /* We can return any write requests */
2722 struct bio *wbi, *wbi2; 2726 struct bio *wbi, *wbi2;
2723 int bitmap_end = 0;
2724 pr_debug("Return write for disc %d\n", i); 2727 pr_debug("Return write for disc %d\n", i);
2725 spin_lock_irq(&conf->device_lock);
2726 wbi = dev->written; 2728 wbi = dev->written;
2727 dev->written = NULL; 2729 dev->written = NULL;
2728 while (wbi && wbi->bi_sector < 2730 while (wbi && wbi->bi_sector <
@@ -2735,15 +2737,10 @@ static void handle_stripe_clean_event(struct r5conf *conf,
2735 } 2737 }
2736 wbi = wbi2; 2738 wbi = wbi2;
2737 } 2739 }
2738 if (dev->towrite == NULL) 2740 bitmap_endwrite(conf->mddev->bitmap, sh->sector,
2739 bitmap_end = 1; 2741 STRIPE_SECTORS,
2740 spin_unlock_irq(&conf->device_lock);
2741 if (bitmap_end)
2742 bitmap_endwrite(conf->mddev->bitmap,
2743 sh->sector,
2744 STRIPE_SECTORS,
2745 !test_bit(STRIPE_DEGRADED, &sh->state), 2742 !test_bit(STRIPE_DEGRADED, &sh->state),
2746 0); 2743 0);
2747 } 2744 }
2748 } 2745 }
2749 2746