]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
md/raid10: fix io loss while replacement replace rdev
authorLi Nan <linan122@huawei.com>
Fri, 2 Jun 2023 09:18:39 +0000 (17:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2023 06:37:05 +0000 (08:37 +0200)
commitbe481881753bdb605db61935b0ffbca9299e5e8a
tree1769d395878b6c3905b497cd3af49a05e51f14b2
parent45fa023b3334a7ae6f6c4eb977295804222dfa28
md/raid10: fix io loss while replacement replace rdev

[ Upstream commit 2ae6aaf76912bae53c74b191569d2ab484f24bf3 ]

When removing a disk with replacement, the replacement will be used to
replace rdev. During this process, there is a brief window in which both
rdev and replacement are read as NULL in raid10_write_request(). This
will result in io not being submitted but it should be.

  //remove //write
  raid10_remove_disk raid10_write_request
   mirror->rdev = NULL
 read rdev -> NULL
   mirror->rdev = mirror->replacement
   mirror->replacement = NULL
 read replacement -> NULL

Fix it by reading replacement first and rdev later, meanwhile, use smp_mb()
to prevent memory reordering.

Fixes: 475b0321a4df ("md/raid10: writes should get directed to replacement as well as original.")
Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230602091839.743798-3-linan666@huaweicloud.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/raid10.c