[Devel] [PATCH VZ10 04/11] drivers/md/dm-stats: propagate operation flags instead of direction
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Mon Jul 13 03:36:37 MSK 2026
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
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko 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 2ede4b51c5a4c..7a465b5e36cd3 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -569,12 +569,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
@@ -644,7 +645,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)
@@ -674,7 +675,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++;
@@ -682,7 +683,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)
@@ -692,6 +693,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;
@@ -724,7 +726,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);
}
--
2.43.5
More information about the Devel
mailing list