Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp663914pxv; Thu, 15 Jul 2021 12:51:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH3IhdwezecuyceR3icJlYGibVHQFtKBEzzemR7XBDa5TIfSczaQ2qoV1yMhJ0N5ZPmwV2 X-Received: by 2002:a17:907:3f9a:: with SMTP id hr26mr7321340ejc.110.1626378682717; Thu, 15 Jul 2021 12:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378682; cv=none; d=google.com; s=arc-20160816; b=N51/XRoV47YiCPUIYXmqb5xORbywiVwEz99ITHqP+v4tSBMVetXiNyO/SDJjgbpuwq wqHmIsgxsJj1mzBGdfCyuJvEMRhGwOCdVAOOmB+ZgCGLnv/yq3yXTmMMKB+P9VcAUzhd NvrBL8hcEpx8CACbJUoWhPorV0s9DpUwZI/ewBrafqnIVl6K+ZJjvA4vVHMT4sgWo0Y2 TkKI+Bv5o5WJYFqT5wNBn/olJxaJsFVADeLB0muvi8w+CkXd7GqNc8p76HIafu8EVraF amEMVulGp+iOPNIEdc9p+9Zy4/e0sPtYKQeANS4mbBbOrlZ4GTrmmMUVeQ8lC9x3ZBtr +XWg== 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=gJlAz8/uAAhVvVKLB6Af5UdTiCkxSVS3vZ2SQXmWQCQ=; b=uTMiK9TyGt/jKwGJ/eTf84C4jHISDPfpfq5YBne7C0FUyw5j6ZwHxKi5GmVzihn9zk 05bEiAw1LhyBkRv1gdFPMm5X16eltRXEuEWGvzeZ5cAlg0e+Imai5Ic0yibt76nK7uk3 YQqGMVSIZMnAnVDsxo54CwfEa3PcVLA6QsVW+FHDM3WEPBNQwQmYEMp419GjJUnlS/3d bqHrhHst/pvYzHXJjMXjOd9La1td2zDpdkkExeI+6BSPtghOgYDeE6JkYY1HCd9vGplU d5lUhFsmCUR46qj0+VHQyI4xBT/7pveGu6XPEssY+puoIA/4pvAgsCWIwyRVKP0i44R2 cq7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hc129YW6; 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 jx17si4579041ejb.15.2021.07.15.12.50.59; Thu, 15 Jul 2021 12:51:22 -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=Hc129YW6; 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 S1344148AbhGOTsN (ORCPT + 99 others); Thu, 15 Jul 2021 15:48:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:58176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242862AbhGOTRN (ORCPT ); Thu, 15 Jul 2021 15:17:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0560F613E9; Thu, 15 Jul 2021 19:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376367; bh=TywS3+8OR6jJVRM/MIr9EVIcjLg13f71Y5+XN6BhK9g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hc129YW6UMHbRDuRbXfcDPAlIs7Jl6fGBa5/dkQBgKuMj4IZOX00Yw/2RtC6586o4 9Mj87NvmvBCDVy4hs6iJN75bg9btKh60E7H8EpDvtgLXY2/BGYRoieCtuT3/OSYxnR ZX1txo9+7EojeeE6ntijktbh51oA0atXH5iALyW8= 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 240/266] dm writecache: flush origin device when writing and cache is full Date: Thu, 15 Jul 2021 20:39:55 +0200 Message-Id: <20210715182650.997401987@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 ee55b92a7391bf871939330f662651b54be51b73 upstream. Commit d53f1fafec9d086f1c5166436abefdaef30e0363 ("dm writecache: do direct write if the cache is full") changed dm-writecache, so that it writes directly to the origin device if the cache is full. Unfortunately, it doesn't forward flush requests to the origin device, so that there is a bug where flushes are being ignored. Fix this by adding missing flush forwarding. For PMEM mode, we fix this bug by disabling direct writes to the origin device, because it performs better. Signed-off-by: Mikulas Patocka Fixes: d53f1fafec9d ("dm writecache: do direct write if the cache is full") Cc: stable@vger.kernel.org # v5.7+ Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-writecache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -1297,8 +1297,12 @@ static int writecache_map(struct dm_targ writecache_flush(wc); if (writecache_has_error(wc)) goto unlock_error; + if (unlikely(wc->cleaner)) + goto unlock_remap_origin; goto unlock_submit; } else { + if (dm_bio_get_target_bio_nr(bio)) + goto unlock_remap_origin; writecache_offload_bio(wc, bio); goto unlock_return; } @@ -1377,7 +1381,7 @@ read_next_block: } e = writecache_pop_from_freelist(wc, (sector_t)-1); if (unlikely(!e)) { - if (!found_entry) { + if (!WC_MODE_PMEM(wc) && !found_entry) { direct_write: e = writecache_find_entry(wc, bio->bi_iter.bi_sector, WFE_RETURN_FOLLOWING); if (e) { @@ -2481,7 +2485,7 @@ overflow: goto bad; } - ti->num_flush_bios = 1; + ti->num_flush_bios = WC_MODE_PMEM(wc) ? 1 : 2; ti->flush_supported = true; ti->num_discard_bios = 1;