diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2021-06-21 14:48:29 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-19 10:04:54 +0200 |
commit | e294f97e8af8542cf4e9c58f09de463b7c03e641 (patch) | |
tree | 2485de27ff57d3137838142575d89b201d256ad4 | |
parent | 691e71cf1fd19e645ec632aee6ae5183112dacfa (diff) | |
download | linux-stable-e294f97e8af8542cf4e9c58f09de463b7c03e641.tar.gz linux-stable-e294f97e8af8542cf4e9c58f09de463b7c03e641.tar.bz2 linux-stable-e294f97e8af8542cf4e9c58f09de463b7c03e641.zip |
dm writecache: write at least 4k when committing
commit 867de40c4c23e6d7f89f9ce4272a5d1b1484c122 upstream.
SSDs perform badly with sub-4k writes (because they perfrorm
read-modify-write internally), so make sure writecache writes at least
4k when committing.
Fixes: 991bd8d7bc78 ("dm writecache: commit just one block, not a full page")
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/md/dm-writecache.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index e942b5d2b6aa..8f891d838cc6 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -532,7 +532,11 @@ static void ssd_commit_superblock(struct dm_writecache *wc) region.bdev = wc->ssd_dev->bdev; region.sector = 0; - region.count = wc->block_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; + region.sector += wc->start_sector; req.bi_op = REQ_OP_WRITE; |