raid5: delete another BUG_ON
PATCH 1/1 raid5: delete another BUG_ON
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.
--- drivers/md/raid5.c | 1 - 1 file changed, 1 deletion(-)
drivers/md/raid5.c +0 -1
@@ -4371,7 +4371,6 @@ static struct stripe_head *__get_priorit }list_del_init (&sh->lru);atomic_inc (&sh->count); -BUG_ON (atomic_read (&sh->count) !=1 );return sh; }
Quoted 15 lines · On Mon, 14 Apr 2014 14:14:17 +0800 Shaohua Li <[email protected]> wrote:
I hit another
BUG_ONwithe240c1839d11152b0355442. In__get_priority_stripe(), stripe count equals to 0 initially. Betweenatomic_incandBUG_ON,get_active_stripe()finds the stripe. So the stripe count isn't 1 any more.Signed-off-by Shaohua Li <[email protected]>--- drivers/md/raid5.c | 1 - 1 file changed, 1 deletion(-)Index:
linux/drivers/md/raid5.c
===================================================================
drivers/md/raid5.c static struct stripe_head *__get_priorit · line 4376
Quoted 7 lines
drivers/md/raid5.c +0
-1@@ -4371,7 +4371,6 @@ static struct stripe_head *__get_priorit }list_del_init (&sh->lru);atomic_inc (&sh->count); -BUG_ON (atomic_read (&sh->count) !=1 );return sh; }
What if we made those two lines:
BUG_ON(atomic_inc_return(&sh->count) != 1);
??
NeilBrown
Quoted 27 lines · NeilBrown
Quoted 15 lines · On Mon, 14 Apr 2014 14:14:17 +0800 Shaohua Li <[email protected]> wrote:
I hit another
BUG_ONwithe240c1839d11152b0355442. In__get_priority_stripe(), stripe count equals to 0 initially. Betweenatomic_incandBUG_ON,get_active_stripe()finds the stripe. So the stripe count isn't 1 any more.Signed-off-by Shaohua Li <[email protected]>--- drivers/md/raid5.c | 1 - 1 file changed, 1 deletion(-)Index:
linux/drivers/md/raid5.c
===================================================================drivers/md/raid5.c static struct stripe_head *__get_priorit · line 4376
Quoted 7 lines
drivers/md/raid5.c +0
-1@@ -4371,7 +4371,6 @@ static struct stripe_head *__get_priorit }list_del_init (&sh->lru);atomic_inc (&sh->count); -BUG_ON (atomic_read (&sh->count) !=1 );return sh; }What if we made those two lines:
Quoted 1 line
BUG_ON(atomic_inc_return(&sh->count) != 1);
Ok if we want to keep the BUG_ON.
Subject: 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.
--- drivers/md/raid5.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/raid5.c +1 -2
@@ -4370,8 +4370,7 @@ static struct stripe_head *__get_priorit 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; }