Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp638080pxv; Thu, 15 Jul 2021 12:09:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3DvQmZz4y1ow6SjAnCuybeiJg72f+UhmWG2/+bpmDldOl2DGvoYfci1pA/porQexeB1Nk X-Received: by 2002:a50:fd8e:: with SMTP id o14mr9193264edt.80.1626376157924; Thu, 15 Jul 2021 12:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376157; cv=none; d=google.com; s=arc-20160816; b=DJbXgsr/CXvkXVQXF4Jb4DHe5XOazYi2E2EM/gzFGkrIcUu5LoxXnCdfuvIwfPlccv JpPcjoqFURaRnE/rFRA/Qy90UxlgTsxFwQoEj4nqQvfTm5/Vs7g7FvO7U4shIjYECa0B VkzQIoFU51lltsZPIhgZYt7jCZuWy73X7iNHCXr34rYX/zSpOXq7U5UzR0z4PF+5bBA8 otOsKX6BXge9GTEIeLAfzIHEYisJwDLXWR7k7Dn3VA2SkHgAxjj5xw5BdvawmEr4vhXI 2+2Z28o3Jy3oxjiMmVRGuqPaqFaTzpwy8cuIUFoDdOkkXdoEE41HLFwP+fHKpeUtHqCk dIgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F1etmMBvmabiUMZdZKIRIuUzjE51wtxnJ0ySXXdee90=; b=Y9hOI7eukzeEeMOHWAhFW/hmIjMwpPs6FqMV5a0QvmHTH6tpB8yaJ+Tx2ION8nPJp8 NyWeBbxHtfhXdBY15suIqAls3h0kJuCrAJhdpJi3B9qPN/KZ0u7OjMAG6hNrnKieHBBf F5fhG5IThNYBTAj8ZA3p2bYid7EtCumLXvF+v5PwaNm9TRo3//DbI1yroW4dFkW0LnEz uvxjzYvtICMxqWQ/Xg2x+y5wWILVdjJwIZV99xAK9NRp9d52a2F5KOanTYU2VkFQh7vL RuKmYgAbRJa4FtD0ztLJ8XPn7FItn6OxeCFOa88bl6J86Ex8x9J0LarzH3/YMMuDLVpv ayVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MicLsVEk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g16si8134839ejt.27.2021.07.15.12.08.54; Thu, 15 Jul 2021 12:09:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MicLsVEk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240854AbhGOTGq (ORCPT + 99 others); Thu, 15 Jul 2021 15:06:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:33134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241669AbhGOS4f (ORCPT ); Thu, 15 Jul 2021 14:56:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE48E613DF; Thu, 15 Jul 2021 18:53:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375214; bh=INyJeFAVFCMDDxPWIB66WGq+MIN1r+ZSRaBmZN4dAmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MicLsVEkcOolqrgPDJ9KziNi5gaC8U5HP3hVY4QSf5sT2i2kbQeAcx2n733ycjPVy sLp1OByj6R8xJ8U/z0GNUX0r9KD2YRhOZjWvxLo8OdM9Cw50wc013OSVRlzoHp5dSC dXu0VJ5By+upWYlau6oLM+kGlvvMxWS9eQJpfx/4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Mike Snitzer Subject: [PATCH 5.10 209/215] dm writecache: write at least 4k when committing Date: Thu, 15 Jul 2021 20:39:41 +0200 Message-Id: <20210715182636.125429718@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikulas Patocka 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 Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-writecache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -532,7 +532,11 @@ static void ssd_commit_superblock(struct 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;