dm: fix double accounting of flush with data
authorMike Snitzer <snitzer@redhat.com>
Fri, 18 Feb 2022 04:39:57 +0000 (23:39 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:22:57 +0000 (14:22 +0200)
commit737d5e25e28d4b06b30bb5f42c1125c0877c4c94
tree9507600c85e831258abe7581177a8d9a4b27d9d3
parentdc77afd7491e46b87a30a08b28ff6492ffb6f1bf
dm: fix double accounting of flush with data

commit 8d394bc4adf588ca4a0650745167cb83f86c18c9 upstream.

DM handles a flush with data by first issuing an empty flush and then
once it completes the REQ_PREFLUSH flag is removed and the payload is
issued.  The problem fixed by this commit is that both the empty flush
bio and the data payload will account the full extent of the data
payload.

Fix this by factoring out dm_io_acct() and having it wrap all IO
accounting to set the size of  bio with REQ_PREFLUSH to 0, account the
IO, and then restore the original size.

Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-stats.c
drivers/md/dm-stats.h
drivers/md/dm.c