Skip to content

Commit

Permalink
dm: add WARN_ON_ONCE to dm_submit_bio_remap
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
snitm committed Mar 10, 2022
1 parent b99fdcd commit 0a8e959
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0a8e959

Please sign in to comment.