Blob Blame History Raw
From 0a8e9599b91db84b25e4f13e89ed9b5cc3c2d15f Mon Sep 17 00:00:00 2001
From: Mike Snitzer <snitzer@redhat.com>
Date: Tue, 8 Mar 2022 17:15:19 -0500
Subject: [PATCH] dm: add WARN_ON_ONCE to dm_submit_bio_remap
Git-commit: 0a8e9599b91db84b25e4f13e89ed9b5cc3c2d15f
Patch-mainline: v5.18-rc1
References: jsc#PED-2765

If a target uses dm_submit_bio_remap() it should set
ti->accounts_remapped_io.

Also, switch dm_start_io_acct() WARN_ON to WARN_ON_ONCE.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Coly Li <colyli@suse.de>

---
 drivers/md/dm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index d9111e17f0fc..1c5c9036a20e 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -541,7 +541,7 @@ static void dm_start_io_acct(struct dm_io *io, struct bio *clone)
 	 * Expect no possibility for race unless is_duplicate_bio.
 	 */
 	if (!clone || likely(!clone_to_tio(clone)->is_duplicate_bio)) {
-		if (WARN_ON(io->was_accounted))
+		if (WARN_ON_ONCE(io->was_accounted))
 			return;
 		io->was_accounted = 1;
 	} else if (xchg(&io->was_accounted, 1) == 1)
@@ -1202,6 +1202,8 @@ void dm_submit_bio_remap(struct bio *clone, struct bio *tgt_clone,
 	struct dm_target_io *tio = clone_to_tio(clone);
 	struct dm_io *io = tio->io;
 
+	WARN_ON_ONCE(!tio->ti->accounts_remapped_io);
+
 	/* establish bio that will get submitted */
 	if (!tgt_clone)
 		tgt_clone = clone;
-- 
2.35.3