[PATCH] dm stats: report actual length for final partial stats row

Samuel Moelius <[email protected]>
Newsgroups dev.linux.lists.dm-devel,org.kernel.vger.linux-kernel
Message-ID <20260609003111.1236975.394ba1811bb8.dm-stats-print-final-step-length@trailofbits.com>
dm_stats_print() emits each row as "<start_sector>+<length> counters".
For a region whose length is not an exact multiple of the configured
step, the last row is shorter than step. The code already clips the row
end to s->end, but still prints step as the length.

Print end - start so the final partial row describes the range that is
actually covered by that row.

Assisted-by: Codex:gpt-5.5-cyber-preview
Signed-off-by: Samuel Moelius <[email protected]>
---
 drivers/md/dm-stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
index c53cf07ab7b0..99e767f892a0 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -895,7 +895,7 @@ static int dm_stats_print(struct dm_stats *stats, int id,
 
 		DMEMIT("%llu+%llu %llu %llu %llu %llu %llu %llu %llu %llu %d %llu %llu %llu %llu",
 		       (unsigned long long)start,
-		       (unsigned long long)step,
+		       (unsigned long long)(end - start),
 		       shared->tmp.ios[READ],
 		       shared->tmp.merges[READ],
 		       shared->tmp.sectors[READ],
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.