diff mbox series

[1/3] md/raid10: record rdev/replacement in struct r10bio

Message ID 20230614084740.1493969-2-linan666@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series md/raid10: record rdev/replacement in r10bio | expand

Commit Message

Li Nan June 14, 2023, 8:47 a.m. UTC
From: Li Nan <linan122@huawei.com>

Getting rdev/replacement from mirror is risky. Replacement can replace
rdev while repl_bio pending, which forces us to add some complex code to
handle this scenario, but there are still some bugs left. Record
rdev/replacement in r10bio and get them from r10bio is a better way. It
is easy to ensure that rdev and replacement remains consistent in io
process, which can help us clean up some code and fix bugs.

Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/raid10.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/md/raid10.h b/drivers/md/raid10.h
index 8c072ce0bc54..261315ffe8c0 100644
--- a/drivers/md/raid10.h
+++ b/drivers/md/raid10.h
@@ -145,12 +145,12 @@  struct r10bio {
 	 */
 	struct r10dev {
 		struct bio	*bio;
-		union {
-			struct bio	*repl_bio; /* used for resync and
-						    * writes */
-			struct md_rdev	*rdev;	   /* used for reads
-						    * (read_slot >= 0) */
-		};
+		/* Currently just used for normal reads and writes */
+		struct md_rdev	*rdev;
+		/* used for resync and writes */
+		struct bio	*repl_bio;
+		/* Currently just used for normal writes */
+		struct md_rdev	*replacement;
 		sector_t	addr;
 		int		devnum;
 	} devs[];