Skip to content

Commit c5d736f

Browse files
Martins3liu-song-6
authored andcommitted
md/raid1: call free_r1bio() before allow_barrier() in raid_end_bio_io()
After allow_barrier, a concurrent raid1_reshape() will replace old mempool and r1conf::raid_disks. Move allow_barrier() to the end of raid_end_bio_io(), so that r1bio can be freed safely. Reviewed-by: Yu Kuai <[email protected]> Signed-off-by: Xueshi Hu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
1 parent ec14a87 commit c5d736f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/md/raid1.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ static void raid_end_bio_io(struct r1bio *r1_bio)
311311
{
312312
struct bio *bio = r1_bio->master_bio;
313313
struct r1conf *conf = r1_bio->mddev->private;
314+
sector_t sector = r1_bio->sector;
314315

315316
/* if nobody has done the final endio yet, do it now */
316317
if (!test_and_set_bit(R1BIO_Returned, &r1_bio->state)) {
@@ -321,13 +322,13 @@ static void raid_end_bio_io(struct r1bio *r1_bio)
321322

322323
call_bio_endio(r1_bio);
323324
}
325+
326+
free_r1bio(r1_bio);
324327
/*
325328
* Wake up any possible resync thread that waits for the device
326329
* to go idle. All I/Os, even write-behind writes, are done.
327330
*/
328-
allow_barrier(conf, r1_bio->sector);
329-
330-
free_r1bio(r1_bio);
331+
allow_barrier(conf, sector);
331332
}
332333

333334
/*

0 commit comments

Comments
 (0)