dm writecache: count number of blocks read, not number of read bios
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 11 Jul 2022 20:30:52 +0000 (16:30 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:13 +0000 (14:23 +0200)
[ Upstream commit 2c6e755b49d273243431f5f1184654e71221fc78 ]

Change dm-writecache, so that it counts the number of blocks read
instead of the number of read bios. Bios can be split and requeued
using the dm_accept_partial_bio function, so counting bios caused
inaccurate results.

Fixes: e3a35d03407c ("dm writecache: add event counters")
Reported-by: Yu Kuai <yukuai1@huaweicloud.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Documentation/admin-guide/device-mapper/writecache.rst
drivers/md/dm-writecache.c

index 10429779a91abc598af92b9432a1ee351cc57b82..7bead3b52690cdac5c12519896cb42a3110b3549 100644 (file)
@@ -78,8 +78,8 @@ Status:
 2. the number of blocks
 3. the number of free blocks
 4. the number of blocks under writeback
-5. the number of read requests
-6. the number of read requests that hit the cache
+5. the number of read blocks
+6. the number of read blocks that hit the cache
 7. the number of write requests
 8. the number of write requests that hit uncommitted block
 9. the number of write requests that hit committed block
index e3d0a9bb27b54e25c55bfe31f52b53322a82f73e..9d6b7b706a6509ba03e4f5049e2a88350a5d332b 100644 (file)
@@ -1364,6 +1364,7 @@ read_next_block:
                }
        } else {
                writecache_map_remap_origin(wc, bio, e);
+               wc->stats.reads += (bio->bi_iter.bi_size - wc->block_size) >> wc->block_size_bits;
                map_op = WC_MAP_REMAP_ORIGIN;
        }