* [dm-devel] [PATCH 2/2] dm: add memory barriers to end_io_acct and dm_wait_for_completion
@ 2022-02-18 20:10 Mikulas Patocka
0 siblings, 0 replies; only message in thread
From: Mikulas Patocka @ 2022-02-18 20:10 UTC (permalink / raw)
To: Mike Snitzer; +Cc: dm-devel
When one thread waits for another, we must use memory barriers, otherwise
the CPU may reorder memory accesses.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
---
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@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-18 20:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 20:10 [dm-devel] [PATCH 2/2] dm: add memory barriers to end_io_acct and dm_wait_for_completion Mikulas Patocka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.