dm: fix double accounting of flush with data
authorMike Snitzer <snitzer@redhat.com>
Tue, 15 Feb 2022 21:06:21 +0000 (16:06 -0500)
committerMike Snitzer <snitzer@redhat.com>
Wed, 16 Feb 2022 20:46:53 +0000 (15:46 -0500)
commit40dd623a5d3ca78ff8efe98bfe2c90275dbf442f
treea9914e774a99e7db4c7487f388f5588d746bdb66
parent3f607293b74d6acb06571a774a500143c1f0ed2c
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.

Also, move kicking of suspend queue to dm_io_dec_pending() and rename
{start,end}_io_acct to dm_{start,end}_io_acct.

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