Skip to content

Commit 1d0ffd2

Browse files
XiaoNi87shligit
authored andcommitted
RAID10 BUG_ON in raise_barrier when force is true and conf->barrier is 0
In raid10 reshape_request it gets max_sectors in read_balance. If the underlayer disks have bad blocks, the max_sectors is less than last. It will call goto read_more many times. It calls raise_barrier(conf, sectors_done != 0) every time. In this condition sectors_done is not 0. So the value passed to the argument force of raise_barrier is true. In raise_barrier it checks conf->barrier when force is true. If force is true and conf->barrier is 0, it panic. In this case reshape_request submits bio to under layer disks. And in the callback function of the bio it calls lower_barrier. If the bio finishes before calling raise_barrier again, it can trigger the BUG_ON. Add one pair of raise_barrier/lower_barrier to fix this bug. Signed-off-by: Xiao Ni <xni@redhat.com> Suggested-by: Neil Brown <neilb@suse.com> Signed-off-by: Shaohua Li <shli@fb.com>
1 parent e254de6 commit 1d0ffd2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/md/raid10.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4529,11 +4529,12 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,
45294529
allow_barrier(conf);
45304530
}
45314531

4532+
raise_barrier(conf, 0);
45324533
read_more:
45334534
/* Now schedule reads for blocks from sector_nr to last */
45344535
r10_bio = raid10_alloc_init_r10buf(conf);
45354536
r10_bio->state = 0;
4536-
raise_barrier(conf, sectors_done != 0);
4537+
raise_barrier(conf, 1);
45374538
atomic_set(&r10_bio->remaining, 0);
45384539
r10_bio->mddev = mddev;
45394540
r10_bio->sector = sector_nr;
@@ -4629,6 +4630,8 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,
46294630
if (sector_nr <= last)
46304631
goto read_more;
46314632

4633+
lower_barrier(conf);
4634+
46324635
/* Now that we have done the whole section we can
46334636
* update reshape_progress
46344637
*/

0 commit comments

Comments
 (0)