[PATCH 2/2] dm: add memory barriers to end_io_acct and dm_wait_for_completion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When one thread waits for another, we must use memory barriers, otherwise
the CPU may reorder memory accesses.

Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx

---
 drivers/md/dm.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Index: linux-2.6/drivers/md/dm.c
===================================================================
--- linux-2.6.orig/drivers/md/dm.c	2022-02-18 17:04:34.000000000 +0100
+++ linux-2.6/drivers/md/dm.c	2022-02-18 17:15:11.000000000 +0100
@@ -506,6 +506,8 @@ static void end_io_acct(struct mapped_de
 				    bio->bi_iter.bi_sector, bio_sectors(bio),
 				    true, duration, stats_aux);
 
+	smp_wmb();
+
 	bio_end_io_acct(bio, start_time);
 
 	/* nudge anyone waiting on suspend queue */
@@ -2170,9 +2172,8 @@ static int dm_wait_for_completion(struct
 	int r = 0;
 
 	if (!queue_is_mq(md->queue))
-		return dm_wait_for_bios_completion(md, task_state);
-
-	while (true) {
+		r = dm_wait_for_bios_completion(md, task_state);
+	else while (true) {
 		if (!blk_mq_queue_inflight(md->queue))
 			break;
 
@@ -2184,6 +2185,8 @@ static int dm_wait_for_completion(struct
 		msleep(5);
 	}
 
+	smp_rmb();
+
 	return r;
 }
 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux