[dm-devel] Patch "dm writecache: count number of blocks discarded, not number of discard bios" has been added to the 5.19-stable tree

Sasha Levin sashal at kernel.org
Sat Aug 13 20:34:16 UTC 2022


This is a note to let you know that I've just added the patch titled

    dm writecache: count number of blocks discarded, not number of discard bios

to the 5.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     dm-writecache-count-number-of-blocks-discarded-not-n.patch
and it can be found in the queue-5.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable at vger.kernel.org> know about it.



commit 08615dcd11b4ef425720325ed53c4ed608083726
Author: Mikulas Patocka <mpatocka at redhat.com>
Date:   Mon Jul 11 16:31:52 2022 -0400

    dm writecache: count number of blocks discarded, not number of discard bios
    
    [ Upstream commit 2ee73ef60db4d79b9f9b8cd501e8188b5179449f ]
    
    Change dm-writecache, so that it counts the number of blocks discarded
    instead of the number of discard bios. Make it consistent with the
    read and write statistics counters that were changed to count the
    number of blocks instead of bios.
    
    Fixes: e3a35d03407c ("dm writecache: add event counters")
    Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>
    Signed-off-by: Mike Snitzer <snitzer at kernel.org>
    Signed-off-by: Sasha Levin <sashal at kernel.org>

diff --git a/Documentation/admin-guide/device-mapper/writecache.rst b/Documentation/admin-guide/device-mapper/writecache.rst
index 6c9a2c74df8a..724e028d1858 100644
--- a/Documentation/admin-guide/device-mapper/writecache.rst
+++ b/Documentation/admin-guide/device-mapper/writecache.rst
@@ -87,7 +87,7 @@ Status:
 11. the number of write blocks that are allocated in the cache
 12. the number of write requests that are blocked on the freelist
 13. the number of flush requests
-14. the number of discard requests
+14. the number of discarded blocks
 
 Messages:
 	flush
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
index d1dca8f44028..b4d5bab8d68b 100644
--- a/drivers/md/dm-writecache.c
+++ b/drivers/md/dm-writecache.c
@@ -1514,7 +1514,7 @@ static enum wc_map_op writecache_map_flush(struct dm_writecache *wc, struct bio
 
 static enum wc_map_op writecache_map_discard(struct dm_writecache *wc, struct bio *bio)
 {
-	wc->stats.discards++;
+	wc->stats.discards += bio->bi_iter.bi_size >> wc->block_size_bits;
 
 	if (writecache_has_error(wc))
 		return WC_MAP_ERROR;



More information about the dm-devel mailing list