dm-stats.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) dm-stats.c (8d394bc4adf588ca4a0650745167cb83f86c18c9)
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/errno.h>
3#include <linux/numa.h>
4#include <linux/slab.h>
5#include <linux/rculist.h>
6#include <linux/threads.h>
7#include <linux/preempt.h>
8#include <linux/irqflags.h>

--- 607 unchanged lines hidden (view full) ---

616 todo -= fragment_len;
617 entry++;
618 offset = 0;
619 } while (unlikely(todo != 0));
620}
621
622void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
623 sector_t bi_sector, unsigned bi_sectors, bool end,
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/errno.h>
3#include <linux/numa.h>
4#include <linux/slab.h>
5#include <linux/rculist.h>
6#include <linux/threads.h>
7#include <linux/preempt.h>
8#include <linux/irqflags.h>

--- 607 unchanged lines hidden (view full) ---

616 todo -= fragment_len;
617 entry++;
618 offset = 0;
619 } while (unlikely(todo != 0));
620}
621
622void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
623 sector_t bi_sector, unsigned bi_sectors, bool end,
624 unsigned long duration_jiffies,
624 unsigned long start_time,
625 struct dm_stats_aux *stats_aux)
626{
627 struct dm_stat *s;
628 sector_t end_sector;
629 struct dm_stats_last_position *last;
630 bool got_precise_time;
625 struct dm_stats_aux *stats_aux)
626{
627 struct dm_stat *s;
628 sector_t end_sector;
629 struct dm_stats_last_position *last;
630 bool got_precise_time;
631 unsigned long duration_jiffies = 0;
631
632 if (unlikely(!bi_sectors))
633 return;
634
635 end_sector = bi_sector + bi_sectors;
636
637 if (!end) {
638 /*
639 * A race condition can at worst result in the merged flag being
640 * misrepresented, so we don't have to disable preemption here.
641 */
642 last = raw_cpu_ptr(stats->last);
643 stats_aux->merged =
644 (bi_sector == (READ_ONCE(last->last_sector) &&
645 ((bi_rw == WRITE) ==
646 (READ_ONCE(last->last_rw) == WRITE))
647 ));
648 WRITE_ONCE(last->last_sector, end_sector);
649 WRITE_ONCE(last->last_rw, bi_rw);
632
633 if (unlikely(!bi_sectors))
634 return;
635
636 end_sector = bi_sector + bi_sectors;
637
638 if (!end) {
639 /*
640 * A race condition can at worst result in the merged flag being
641 * misrepresented, so we don't have to disable preemption here.
642 */
643 last = raw_cpu_ptr(stats->last);
644 stats_aux->merged =
645 (bi_sector == (READ_ONCE(last->last_sector) &&
646 ((bi_rw == WRITE) ==
647 (READ_ONCE(last->last_rw) == WRITE))
648 ));
649 WRITE_ONCE(last->last_sector, end_sector);
650 WRITE_ONCE(last->last_rw, bi_rw);
650 }
651 } else
652 duration_jiffies = jiffies - start_time;
651
652 rcu_read_lock();
653
654 got_precise_time = false;
655 list_for_each_entry_rcu(s, &stats->list, list_entry) {
656 if (s->stat_flags & STAT_PRECISE_TIMESTAMPS && !got_precise_time) {
657 if (!end)
658 stats_aux->duration_ns = ktime_to_ns(ktime_get());

--- 551 unchanged lines hidden ---
653
654 rcu_read_lock();
655
656 got_precise_time = false;
657 list_for_each_entry_rcu(s, &stats->list, list_entry) {
658 if (s->stat_flags & STAT_PRECISE_TIMESTAMPS && !got_precise_time) {
659 if (!end)
660 stats_aux->duration_ns = ktime_to_ns(ktime_get());

--- 551 unchanged lines hidden ---