mirror of
https://github.com/torvalds/linux.git
synced 2024-12-05 10:32:35 +00:00
0cdb90f0f3
dm_stats_account_io()'s STAT_PRECISE_TIMESTAMPS support doesn't handle the fact that with commitb879f915bc
("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:b879f915bc
("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>
49 lines
1.1 KiB
C
49 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef DM_STATS_H
|
|
#define DM_STATS_H
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/list.h>
|
|
|
|
int dm_statistics_init(void);
|
|
void dm_statistics_exit(void);
|
|
|
|
struct dm_stats {
|
|
struct mutex mutex;
|
|
struct list_head list; /* list of struct dm_stat */
|
|
struct dm_stats_last_position __percpu *last;
|
|
bool precise_timestamps;
|
|
};
|
|
|
|
struct dm_stats_aux {
|
|
bool merged;
|
|
unsigned long long duration_ns;
|
|
};
|
|
|
|
void dm_stats_init(struct dm_stats *st);
|
|
void dm_stats_cleanup(struct dm_stats *st);
|
|
|
|
struct mapped_device;
|
|
|
|
int dm_stats_message(struct mapped_device *md, unsigned argc, char **argv,
|
|
char *result, unsigned maxlen);
|
|
|
|
void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
|
|
sector_t bi_sector, unsigned bi_sectors, bool end,
|
|
unsigned long start_time,
|
|
struct dm_stats_aux *aux);
|
|
|
|
static inline bool dm_stats_used(struct dm_stats *st)
|
|
{
|
|
return !list_empty(&st->list);
|
|
}
|
|
|
|
static inline void dm_stats_record_start(struct dm_stats *stats, struct dm_stats_aux *aux)
|
|
{
|
|
if (unlikely(stats->precise_timestamps))
|
|
aux->duration_ns = ktime_to_ns(ktime_get());
|
|
}
|
|
|
|
#endif
|