Commit c5d736f5 authored by Xueshi Hu's avatar Xueshi Hu Committed by Song Liu

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: default avatarYu Kuai <yukuai3@huawei.com>
Signed-off-by: default avatarXueshi Hu <xueshi.hu@smartx.com>
Link: https://lore.kernel.org/r/20230814135356.1113639-2-xueshi.hu@smartx.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent ec14a87e
...@@ -311,6 +311,7 @@ static void raid_end_bio_io(struct r1bio *r1_bio) ...@@ -311,6 +311,7 @@ static void raid_end_bio_io(struct r1bio *r1_bio)
{ {
struct bio *bio = r1_bio->master_bio; struct bio *bio = r1_bio->master_bio;
struct r1conf *conf = r1_bio->mddev->private; struct r1conf *conf = r1_bio->mddev->private;
sector_t sector = r1_bio->sector;
/* if nobody has done the final endio yet, do it now */ /* if nobody has done the final endio yet, do it now */
if (!test_and_set_bit(R1BIO_Returned, &r1_bio->state)) { if (!test_and_set_bit(R1BIO_Returned, &r1_bio->state)) {
...@@ -321,13 +322,13 @@ static void raid_end_bio_io(struct r1bio *r1_bio) ...@@ -321,13 +322,13 @@ static void raid_end_bio_io(struct r1bio *r1_bio)
call_bio_endio(r1_bio); call_bio_endio(r1_bio);
} }
free_r1bio(r1_bio);
/* /*
* Wake up any possible resync thread that waits for the device * Wake up any possible resync thread that waits for the device
* to go idle. All I/Os, even write-behind writes, are done. * to go idle. All I/Os, even write-behind writes, are done.
*/ */
allow_barrier(conf, r1_bio->sector); allow_barrier(conf, sector);
free_r1bio(r1_bio);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment