diff options
author | Yu Kuai <yukuai3@huawei.com> | 2023-05-29 16:11:05 +0300 |
---|---|---|
committer | Song Liu <song@kernel.org> | 2023-06-14 01:25:44 +0300 |
commit | 9efcc2c3df7612eea02daa159ae7c6ac44420513 (patch) | |
tree | 24fc507db66f76f1b31b4a05ced89b7c169fa479 /drivers/md/raid1-10.c | |
parent | a022325ab970cf04b66ca128a87345714aa44b99 (diff) | |
download | linux-9efcc2c3df7612eea02daa159ae7c6ac44420513.tar.xz |
md/raid1-10: don't handle pluged bio by daemon thread
current->bio_list will be set under submit_bio() context, in this case
bitmap io will be added to the list and wait for current io submission to
finish, while current io submission must wait for bitmap io to be done.
commit 874807a83139 ("md/raid1{,0}: fix deadlock in bitmap_unplug.") fix
the deadlock by handling plugged bio by daemon thread.
On the one hand, the deadlock won't exist after commit a214b949d8e3
("blk-mq: only flush requests from the plug in blk_mq_submit_bio"). On
the other hand, current solution makes it impossible to flush plugged bio
in raid1/10_make_request(), because this will cause that all the writes
will goto daemon thread.
In order to limit the number of plugged bio, commit 874807a83139
("md/raid1{,0}: fix deadlock in bitmap_unplug.") is reverted, and the
deadlock is fixed by handling bitmap io asynchronously.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230529131106.2123367-7-yukuai1@huaweicloud.com
Diffstat (limited to 'drivers/md/raid1-10.c')
-rw-r--r-- | drivers/md/raid1-10.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/md/raid1-10.c b/drivers/md/raid1-10.c index 52469e460dab..c62bcb17c67b 100644 --- a/drivers/md/raid1-10.c +++ b/drivers/md/raid1-10.c @@ -152,3 +152,17 @@ static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio, return true; } + +/* + * current->bio_list will be set under submit_bio() context, in this case bitmap + * io will be added to the list and wait for current io submission to finish, + * while current io submission must wait for bitmap io to be done. In order to + * avoid such deadlock, submit bitmap io asynchronously. + */ +static inline void raid1_prepare_flush_writes(struct bitmap *bitmap) +{ + if (current->bio_list) + md_bitmap_unplug_async(bitmap); + else + md_bitmap_unplug(bitmap); +} |