dm: fix double accounting of flush with data
authorMike Snitzer <snitzer@redhat.com>
Fri, 18 Feb 2022 04:39:57 +0000 (23:39 -0500)
committerMike Snitzer <snitzer@redhat.com>
Mon, 21 Feb 2022 20:35:25 +0000 (15:35 -0500)
commit8d394bc4adf588ca4a0650745167cb83f86c18c9
treeacf42f01698400207c0bdcbcdc6b2a5cd589fd98
parent9f6dc633761006f974701d4c88da71ab68670749
dm: fix double accounting of flush with data

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>
drivers/md/dm-stats.c
drivers/md/dm-stats.h
drivers/md/dm.c