Archived
14
0
Fork 0

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>
This commit is contained in:
Shaohua Li 2012-07-19 16:01:31 +10:00 committed by NeilBrown
parent e7836bd6f6
commit 7eaf7e8eb3

View file

@ -2357,7 +2357,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
spin_lock_irq(&conf->device_lock); spin_lock_irq(&conf->device_lock);
if (forwrite) { if (forwrite) {
bip = &sh->dev[dd_idx].towrite; bip = &sh->dev[dd_idx].towrite;
if (*bip == NULL && sh->dev[dd_idx].written == NULL) if (*bip == NULL)
firstwrite = 1; firstwrite = 1;
} else } else
bip = &sh->dev[dd_idx].toread; bip = &sh->dev[dd_idx].toread;
@ -2458,6 +2458,7 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
/* fail all writes first */ /* fail all writes first */
bi = sh->dev[i].towrite; bi = sh->dev[i].towrite;
sh->dev[i].towrite = NULL; sh->dev[i].towrite = NULL;
spin_unlock_irq(&conf->device_lock);
if (bi) { if (bi) {
s->to_write--; s->to_write--;
bitmap_end = 1; bitmap_end = 1;
@ -2477,6 +2478,10 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
} }
bi = nextbi; bi = nextbi;
} }
if (bitmap_end)
bitmap_endwrite(conf->mddev->bitmap, sh->sector,
STRIPE_SECTORS, 0, 0);
bitmap_end = 0;
/* and fail all 'written' */ /* and fail all 'written' */
bi = sh->dev[i].written; bi = sh->dev[i].written;
sh->dev[i].written = NULL; sh->dev[i].written = NULL;
@ -2516,7 +2521,6 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
bi = nextbi; bi = nextbi;
} }
} }
spin_unlock_irq(&conf->device_lock);
if (bitmap_end) if (bitmap_end)
bitmap_endwrite(conf->mddev->bitmap, sh->sector, bitmap_endwrite(conf->mddev->bitmap, sh->sector,
STRIPE_SECTORS, 0, 0); STRIPE_SECTORS, 0, 0);
@ -2720,9 +2724,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
test_bit(R5_UPTODATE, &dev->flags)) { test_bit(R5_UPTODATE, &dev->flags)) {
/* We can return any write requests */ /* We can return any write requests */
struct bio *wbi, *wbi2; struct bio *wbi, *wbi2;
int bitmap_end = 0;
pr_debug("Return write for disc %d\n", i); pr_debug("Return write for disc %d\n", i);
spin_lock_irq(&conf->device_lock);
wbi = dev->written; wbi = dev->written;
dev->written = NULL; dev->written = NULL;
while (wbi && wbi->bi_sector < while (wbi && wbi->bi_sector <
@ -2735,12 +2737,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
} }
wbi = wbi2; wbi = wbi2;
} }
if (dev->towrite == NULL) bitmap_endwrite(conf->mddev->bitmap, sh->sector,
bitmap_end = 1;
spin_unlock_irq(&conf->device_lock);
if (bitmap_end)
bitmap_endwrite(conf->mddev->bitmap,
sh->sector,
STRIPE_SECTORS, STRIPE_SECTORS,
!test_bit(STRIPE_DEGRADED, &sh->state), !test_bit(STRIPE_DEGRADED, &sh->state),
0); 0);