projects/linux·commit c7a6d35e

raid5: fix a race of stripe count check

c7a6d35e · Shaohua Li <[email protected]> · 2014-04-15 09:12:54 +08:00

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 <[email protected]>
Signed-off-by: NeilBrown <[email protected]>
Commit
c7a6d35e463caacab08ca0333bdec5b8bdce8bbb
Parents
e240c183

Changes

1 files changed · +1 −2

FileStatusAddDelContent
drivers/md/raid5.cmodified+1−2View file

drivers/md/raid5.c

View file
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 25247a8..ad1b9be 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)
sh->group = NULL;
}
list_del_init(&sh->lru);
- atomic_inc(&sh->count);
- BUG_ON(atomic_read(&sh->count) != 1);
+ BUG_ON(atomic_inc_return(&sh->count) != 1);
return sh;
}