Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp663868pxv; Thu, 15 Jul 2021 12:51:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxThwJEgHTUdUWhc3v/Angcg5Zjd2FTB/kPfn7Z5cxQH8OMvfWYZP/G8t0VF1pBE4Z7PCAK X-Received: by 2002:a05:6602:1814:: with SMTP id t20mr68644ioh.204.1626378678696; Thu, 15 Jul 2021 12:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378678; cv=none; d=google.com; s=arc-20160816; b=QBSKCbBqfDMdmW4LJVj+FCOxAu4znLwR4914Ft2aCTl1iI+mG4LULmWYVmrzewnfE4 b4jr1ID4nNhPOlE43CAn+9juvhRK0S97O0g6PW3sVtx8MPebEaK7g9E0GLhUzsNe6P8c 8deZxYcgYmBgQXJrcfLvSeZF80szNfnHUFuSSb6tqT9FntP5IZOIGVkAe2nFrnTQbEVC RxP0Eq8n59PKuuGhhzuzG9gKiPnRsLwcga8rYT81FYhGJD8spiKlxBUEEhBSsR6xZuBo y0UneaMCBr7lrasbm2COeygrzvTZ2ckwYcY9nN9kArBQ8ROgaOZ/57nN5kUhXPmworJt 010A== 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=wbayoQ9nGvjGP/wK48PXYCuXCNN9B7A9nNfZqo+Yg+fuP5pA2ef/KvQlubGKY4Z1xB 0isIC/rkbvxAxKOB08LXdCWvz0cICymTUuzZ83godMlaplLAj7FADyhR3tMEnf9PxTx2 iG0hAjt0k3zWnZXufU491fRbwxCACK5KWpyr1IFC4sbTuBBOCgU9/Iiky2BSwwJAK6gN 4xiMcAwyV6X3oXNaVQY9LaVvijObKVoOYvvwhsqQ1yLwev7+TpHX/L2KFgjsvp57w2GO 5TFiEm5QE0GtU+o/XF7PIwO3t8fxr22v05N/0jcgMkFG1pUstTHBtjcvgRG9B8B8I1r6 izWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uKy9RZk3; 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 z16si7033254ilm.29.2021.07.15.12.51.06; Thu, 15 Jul 2021 12:51:18 -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=uKy9RZk3; 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 S245450AbhGOTwo (ORCPT + 99 others); Thu, 15 Jul 2021 15:52:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:57714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244463AbhGOTSM (ORCPT ); Thu, 15 Jul 2021 15:18:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E95B8613D8; Thu, 15 Jul 2021 19:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376407; bh=INyJeFAVFCMDDxPWIB66WGq+MIN1r+ZSRaBmZN4dAmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uKy9RZk3p6WyNvymFUhHIgsySy58zGF28g/ETcNXS2NP8Ko66XqPUoSmmxzzqc7s9 +KXCQ+Q3fdSJEEvwwcLx1I/mS9LM50ttKipxUIzPiStqM6/VYpMhOHxhfpHrOIX4L8 prTHZvx1J14UgDt3H02xd0348WOyhnXcShqvsOoQ= 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.13 259/266] dm writecache: write at least 4k when committing Date: Thu, 15 Jul 2021 20:40:14 +0200 Message-Id: <20210715182652.968417796@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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;