[Devel] [PATCH RHEL10 COMMIT] drivers/md/dm-stats: propagate operation flags instead of direction
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jul 31 15:11:51 MSK 2026
The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.1.vz10
------>
commit 4ce7db2b1e20dfa2c6e4fed0f8e66317d4298cad
Author: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Date: Mon Jul 27 19:32:47 2026 +0300
drivers/md/dm-stats: propagate operation flags instead of direction
This patch allows to better differentiate between I/O types. It will
be used later to implement read/write/flush histograms.
https://virtuozzo.atlassian.net/browse/VSTOR-103846
Feature: dm-stats: latency and histogram enhancements
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Reviewed-by: Vasileios Almpanis <vasileios.almpanis at virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
drivers/md/dm-rq.c | 4 ++--
drivers/md/dm-stats.c | 12 +++++++-----
drivers/md/dm-stats.h | 2 +-
drivers/md/dm.c | 2 +-
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index 28bd496143770..20f495bf5399d 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -133,7 +133,7 @@ static void rq_end_stats(struct mapped_device *md, struct request *orig)
tio->stats_aux.histogram_duration_ns =
bio_issue_elapsed_ns(orig->bio);
- dm_stats_account_io(&md->stats, rq_data_dir(orig),
+ dm_stats_account_io(&md->stats, orig->cmd_flags,
blk_rq_pos(orig), tio->n_sectors, true,
tio->duration_jiffies, &tio->stats_aux);
}
@@ -453,7 +453,7 @@ static void dm_start_request(struct mapped_device *md, struct request *orig)
tio->n_sectors = blk_rq_sectors(orig);
dm_stats_record_start(&md->stats, &tio->stats_aux);
- dm_stats_account_io(&md->stats, rq_data_dir(orig),
+ dm_stats_account_io(&md->stats, orig->cmd_flags,
blk_rq_pos(orig), tio->n_sectors, false, 0,
&tio->stats_aux);
}
diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
index 7c0551737a696..49e19c413ce13 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -570,12 +570,13 @@ static void dm_stat_round(struct dm_stat *s, struct dm_stat_shared *shared,
}
static void dm_stat_for_entry(struct dm_stat *s, size_t entry,
- int idx, sector_t len,
+ blk_opf_t bi_opf, sector_t len,
struct dm_stats_aux *stats_aux, bool end,
unsigned long duration_jiffies)
{
struct dm_stat_shared *shared = &s->stat_shared[entry];
struct dm_stat_percpu *p;
+ int idx = op_is_write(bi_opf);
/*
* For strict correctness we should use local_irq_save/restore
@@ -645,7 +646,7 @@ static void dm_stat_for_entry(struct dm_stat *s, size_t entry,
#endif
}
-static void __dm_stat_bio(struct dm_stat *s, int bi_rw,
+static void __dm_stat_bio(struct dm_stat *s, blk_opf_t bi_opf,
sector_t bi_sector, sector_t end_sector,
bool end, unsigned long duration_jiffies,
struct dm_stats_aux *stats_aux)
@@ -675,7 +676,7 @@ static void __dm_stat_bio(struct dm_stat *s, int bi_rw,
fragment_len = todo;
if (fragment_len > s->step - offset)
fragment_len = s->step - offset;
- dm_stat_for_entry(s, entry, bi_rw, fragment_len,
+ dm_stat_for_entry(s, entry, bi_opf, fragment_len,
stats_aux, end, duration_jiffies);
todo -= fragment_len;
entry++;
@@ -683,7 +684,7 @@ static void __dm_stat_bio(struct dm_stat *s, int bi_rw,
} while (unlikely(todo != 0));
}
-void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
+void dm_stats_account_io(struct dm_stats *stats, blk_opf_t bi_opf,
sector_t bi_sector, unsigned int bi_sectors, bool end,
unsigned long start_time,
struct dm_stats_aux *stats_aux)
@@ -693,6 +694,7 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
struct dm_stats_last_position *last;
bool got_precise_time;
unsigned long duration_jiffies = 0;
+ unsigned long bi_rw = op_is_write(bi_opf);
if (unlikely(!bi_sectors))
return;
@@ -725,7 +727,7 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
stats_aux->duration_ns = ktime_to_ns(ktime_get()) - stats_aux->duration_ns;
got_precise_time = true;
}
- __dm_stat_bio(s, bi_rw, bi_sector, end_sector, end, duration_jiffies, stats_aux);
+ __dm_stat_bio(s, bi_opf, bi_sector, end_sector, end, duration_jiffies, stats_aux);
}
rcu_read_unlock();
diff --git a/drivers/md/dm-stats.h b/drivers/md/dm-stats.h
index cce68414b97ee..1da681c89d127 100644
--- a/drivers/md/dm-stats.h
+++ b/drivers/md/dm-stats.h
@@ -31,7 +31,7 @@ struct mapped_device;
int dm_stats_message(struct mapped_device *md, unsigned int argc, char **argv,
char *result, unsigned int maxlen);
-void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
+void dm_stats_account_io(struct dm_stats *stats, blk_opf_t bi_op,
sector_t bi_sector, unsigned int bi_sectors, bool end,
unsigned long start_time,
struct dm_stats_aux *aux);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 7029201480358..0d157be57d381 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -578,7 +578,7 @@ static void dm_io_acct(struct dm_io *io, bool end)
else
sector = bio->bi_iter.bi_sector;
- dm_stats_account_io(&io->md->stats, bio_data_dir(bio),
+ dm_stats_account_io(&io->md->stats, bio->bi_opf,
sector, dm_io_sectors(io, bio),
end, io->start_time, &io->stats_aux);
}
More information about the Devel
mailing list