dm stats: fix too short end duration_ns with STAT_PRECISE_TIMESTAMPS
authorMike Snitzer <snitzer@redhat.com>
Wed, 16 Feb 2022 15:13:30 +0000 (10:13 -0500)
committerMike Snitzer <snitzer@redhat.com>
Wed, 16 Feb 2022 20:47:21 +0000 (15:47 -0500)
commit6297dd04f40d1c1ac8a81ba4b9d2d46d0ab50225
tree1d7e116ea314877deb85f78a429be3bebe4b8991
parent40dd623a5d3ca78ff8efe98bfe2c90275dbf442f
dm stats: fix too short end duration_ns with STAT_PRECISE_TIMESTAMPS

dm_stats_account_io()'s STAT_PRECISE_TIMESTAMPS support doesn't handle
the fact that with commit b879f915bc48 ("dm: properly fix redundant
bio-based IO accounting") io->start_time _may_ be in the past (meaning
the start_io_acct() was deferred until later).

Add a new dm_stats_recalc_precise_timestamps() helper that will
set/clear a new 'precise_timestamps' flag in the dm_stats struct based
on whether any configured stats enable STAT_PRECISE_TIMESTAMPS.
And update DM core's alloc_io() to use dm_stats_record_start() to set
stats_aux.duration_ns if stats->precise_timestamps is true.

Also, remove unused 'last_sector' and 'last_rw' members from the
dm_stats struct.

Fixes: b879f915bc48 ("dm: properly fix redundant bio-based IO accounting")
Cc: stable@vger.kernel.org
Co-developed-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-stats.c
drivers/md/dm-stats.h
drivers/md/dm.c