Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp647892pxv; Thu, 15 Jul 2021 12:24:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzfvCUfUbvmEyioaglpYQ0BPsKpU293tobFBBzySsspsjQBeu3B4zw8cgo2O+xn/t6hJVr X-Received: by 2002:a17:906:f0d1:: with SMTP id dk17mr7197925ejb.424.1626377082413; Thu, 15 Jul 2021 12:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377082; cv=none; d=google.com; s=arc-20160816; b=gQu8BjNedIfbeDEaPeDYe1cQkKnYEslGW9jP0hjMf78LcSeGAUpmGyKw4xJ6bwznEa 6m/yarcQ6KExjFDzszHUtMadtTq36X0QJmgOUF88TShuPQ0fb66em5sYHCopCOmajAA/ SZ0e1hY+ZkkrEzXd/kK+/shwjIa/S/L+nT3MrwRw15pjVnUtdCmiEkImeBPp6Rel9MgX 44J6KkuOcR8RXYtEc1auFiPIb0Kcc1VIRQTo0Tf1Q3gppm9hRFOiCGS11QHnamF+/1Ri 1VRGUynwV70SYbjrjIKp1gge2sbv+oWb25HfS7uJGkQmuxOs63b+5NHhr2SZQs4FlO1x znlg== 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=YCZjAJNhbB4DpD8gS1oEAkS6MCSg6w/7KTDitmGxykFNjo81NCtGhVZEl19oyNiJBW +PL0c0ViiKIxGlr9gSgdmaSZCSdWtLhUypeZDfbTQm3n1gYeDHUMLsd5qGdll+1pIsBX pVPXYNthYJc5CMic6QYncvDKEdymak86Jnou8hYlGL5mwev+edMwVV7bvup2C5J1mQc3 DrNlt8SJ3hgnC894524DpFqLQnSgzolnrEe9txeBgJgdpOkj2yEYAfapAn+227URBDaT Q+F3Hh5dLzixkmr9IMEUlm+SrLqcx87E8y2TiJtPjTj9xEGnJxmVuSpPPvmMXNbFJSza lqOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GJk26Q+C; 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 a21si8404541edy.79.2021.07.15.12.24.17; Thu, 15 Jul 2021 12:24:42 -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=GJk26Q+C; 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 S245443AbhGOTXt (ORCPT + 99 others); Thu, 15 Jul 2021 15:23:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:46412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242503AbhGOTGx (ORCPT ); Thu, 15 Jul 2021 15:06:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 386B1613D4; Thu, 15 Jul 2021 19:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375787; bh=INyJeFAVFCMDDxPWIB66WGq+MIN1r+ZSRaBmZN4dAmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GJk26Q+CPvn34vrA2axvbH1YwiKetLB/J2g3CAv2X7jNFTEvV+mXgjh0MaxyaIExQ Q5rSCqXIUEEfjZ3wJINM8McmER3tY+ZEJehrpQDM9jE+NoH5enP6wKA4IHRAX16VM7 IRmVileBKopFSk6SMpQ6lBhD9msFyAWtKbUbZV7A= 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.12 235/242] dm writecache: write at least 4k when committing Date: Thu, 15 Jul 2021 20:39:57 +0200 Message-Id: <20210715182634.215340090@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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;