[dm-devel] [PATCH 1/1] dm writecache: commit just one block, not a full page

Mikulas Patocka mpatocka at redhat.com
Mon Jun 21 18:09:02 UTC 2021


Some architectures have pages larger than 4k and committing a full page
causes needless overhead.

Fix this by writing a single block when committing the superblock.

Writes smaller than 4k are slow on most SSDs (because the SSD performs
read-modify-write internally), so make sure that we write at least 4k.

Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>

Index: linux-2.6/drivers/md/dm-writecache.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-writecache.c
+++ linux-2.6/drivers/md/dm-writecache.c
@@ -532,7 +532,7 @@ static void ssd_commit_superblock(struct
 
 	region.bdev = wc->ssd_dev->bdev;
 	region.sector = 0;
-	region.count = PAGE_SIZE >> SECTOR_SHIFT;
+	region.count = max(4096U, wc->block_size) >> SECTOR_SHIFT;
 
 	if (unlikely(region.sector + region.count > wc->metadata_sectors))
 		region.count = wc->metadata_sectors - region.sector;




More information about the dm-devel mailing list