diff mbox series

[v4.14] dm: interlock pending dm_io and dm_wait_for_bios_completion

Message ID alpine.LRH.2.02.2205031635530.11434@file01.intranet.prod.int.rdu2.redhat.com
State New
Headers show
Series [v4.14] dm: interlock pending dm_io and dm_wait_for_bios_completion | expand

Commit Message

Mikulas Patocka May 3, 2022, 8:37 p.m. UTC
This is backport of the patch 9f6dc6337610 ("dm: interlock pending dm_io
and dm_wait_for_bios_completion") for the kernel 4.14.

The bugs fixed by this patch can cause random crashing when reloading dm
table, so it is eligible for stable backport.

Note that the kernel 4.14 uses md->pending to count the number of
in-progress I/Os and md->pending is decremented after dm_stats_account_io,
so the race condition doesn't really exist there (except for missing
smp_rmb()).

The percpu variable md->pending_io is not needed in the stable kernels,
because md->pending counts the same value, so it is not backported.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>

---
 drivers/md/dm.c |    2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

Index: linux-stable/drivers/md/dm.c
===================================================================
--- linux-stable.orig/drivers/md/dm.c	2022-04-30 19:16:55.000000000 +0200
+++ linux-stable/drivers/md/dm.c	2022-04-30 19:16:55.000000000 +0200
@@ -2230,6 +2230,8 @@  static int dm_wait_for_completion(struct
 	}
 	finish_wait(&md->wait, &wait);
 
+	smp_rmb(); /* paired with atomic_dec_return in end_io_acct */
+
 	return r;
 }