[PATCH OLK-6.6] md: use bio_alloc when sync_set is not initialized in md_super_write
hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/9983 -------------------------------- Commit 6a5965696856 removed md_bio_alloc_sync and used bio_alloc_bioset instead. But when md_super_write is called after __md_stop has destroyed sync_set, bio_alloc_bioset with &mddev->sync_set triggers WARN_ON_ONCE because the bioset is not initialized. Fall back to bio_alloc (which uses fs_bio_set) when sync_set is not initialized. Fixes: 6a5965696856 ("md: remove md_bio_alloc_sync") Signed-off-by: Ran Hongyun <ranhongyun1@huawei.com> --- drivers/md/md.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 2a32de5f5b64..a501fe675893 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1075,6 +1075,9 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev, * If an error occurred, call md_error */ struct bio *bio; + struct block_device *bdev; + blk_opf_t opf = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE | REQ_META + | REQ_PREFLUSH | REQ_FUA; if (!page) return; @@ -1082,11 +1085,12 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev, if (test_bit(Faulty, &rdev->flags)) return; - bio = bio_alloc_bioset(rdev->meta_bdev ? rdev->meta_bdev : rdev->bdev, - 1, - REQ_OP_WRITE | REQ_SYNC | REQ_IDLE | REQ_META - | REQ_PREFLUSH | REQ_FUA, - GFP_NOIO, &mddev->sync_set); + bdev = rdev->meta_bdev ? rdev->meta_bdev : rdev->bdev; + + if (bioset_initialized(&mddev->sync_set)) + bio = bio_alloc_bioset(bdev, 1, opf, GFP_NOIO, &mddev->sync_set); + else + bio = bio_alloc(bdev, 1, opf, GFP_NOIO); atomic_inc(&rdev->nr_pending); -- 2.52.0
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://atomgit.com/openeuler/kernel/merge_requests/27824 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/L26... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://atomgit.com/openeuler/kernel/merge_requests/27824 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/L26...
participants (2)
-
patchwork bot -
Ran Hongyun