aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShaohua Li <shli@kernel.org>2014-04-14 21:12:54 -0400
committerNeilBrown <neilb@suse.de>2014-04-17 03:05:28 -0400
commitc7a6d35e463caacab08ca0333bdec5b8bdce8bbb (patch)
treebf4abac968402f11ba3d26e238ab62173f2bb23a
parente240c1839d11152b0355442f8ac6d2d2d921be36 (diff)
raid5: fix a race of stripe count check
I hit another BUG_ON with e240c1839d11152b0355442. In __get_priority_stripe(), stripe count equals to 0 initially. Between atomic_inc and BUG_ON, get_active_stripe() finds the stripe. So the stripe count isn't 1 any more. V2: keeps the BUG_ON suggested by Neil. Signed-off-by: Shaohua Li <shli@fusionio.com> Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/raid5.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 25247a852912..ad1b9bea446e 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4370,8 +4370,7 @@ static struct stripe_head *__get_priority_stripe(struct r5conf *conf, int group)
4370 sh->group = NULL; 4370 sh->group = NULL;
4371 } 4371 }
4372 list_del_init(&sh->lru); 4372 list_del_init(&sh->lru);
4373 atomic_inc(&sh->count); 4373 BUG_ON(atomic_inc_return(&sh->count) != 1);
4374 BUG_ON(atomic_read(&sh->count) != 1);
4375 return sh; 4374 return sh;
4376} 4375}
4377 4376