Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2417312ybz; Sun, 19 Apr 2020 00:47:49 -0700 (PDT) X-Google-Smtp-Source: APiQypI+hbkabYCyEmfI49j1fkc/IN3nx4zwMcNkalvrwT0TlPzctdrelQMj9SdKhr0EMmT4gSag X-Received: by 2002:a50:fc0d:: with SMTP id i13mr2528207edr.280.1587282469681; Sun, 19 Apr 2020 00:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587282469; cv=none; d=google.com; s=arc-20160816; b=TxgLg5NNmDnYJhR4B60JiWOAJAbNi/gdZfrMwcnMeHfKrLoWi20NkhVdCNwGGmq5kr m2WZgXC2urxzj8lRLQTUCaEuqgmnPwCYG+yaTtPoctzmdGFs4Sq2wSbefxu/Sk9YM5lX HrdAZIteTquv8BDsiF3d1FBGeU/ykJ1yM7Ik8mzmUaIZ7PjqYwm4pTskdgBcxU9nN96H zle6eDUgCEDApOCgJWHvKKWS50qLFkNKJsjYZjhnsz/soKvnv9jgIc/653cBOMJ3KAkz RHFTa1YXJsubCVExClDYipuYtjUEQb1flYg4ARX/PfoNrcp6AptaOI+alts04Jg/tO3m Ewrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TMAnfOUpBWXaS11G69bxRWvNmWErGaYvEk8u2l13Vmg=; b=l9Saz4lvKa+tv4M60Tnc/lruxacQg6n97echBnFKFQZWCecVbahQdoDLUSHcc/InfH p03HKG77JAiph88iOQo8DSiKoMVVSECTIQdpzx5rxhLUv0Xowpb4Vm5xD3oVMuDcfOSz YWuPKMzUrRhuxZUUmjnEbX2Z8U2PsPIGRY3Xr6gEaGWgcMQ6TN6PqY1AuAFMnEJoFEMQ lWxZ0BvkVmllbGrikTCy2hXMhMRxn9J5MNJ+njRpi+RjtES23sEYDbdmD/T5iW8hgoBT E02+NGfslbWTSiqGut21DJhf9lVuPFRdUSlqXkFMI2lHWG5JmrPn8h7XuoAe2gzx06ld 2rAg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bonedaddy.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si4216780edn.236.2020.04.19.00.47.26; Sun, 19 Apr 2020 00:47:49 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bonedaddy.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726007AbgDSHp1 (ORCPT + 99 others); Sun, 19 Apr 2020 03:45:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725903AbgDSHp0 (ORCPT ); Sun, 19 Apr 2020 03:45:26 -0400 Received: from master.debian.org (master.debian.org [IPv6:2001:41b8:202:deb:216:36ff:fe40:4001]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9DC5C061A0C for ; Sun, 19 Apr 2020 00:45:26 -0700 (PDT) Received: from pabs by master.debian.org with local (Exim 4.92) (envelope-from ) id 1jQ4QD-00040m-1R; Sun, 19 Apr 2020 07:31:21 +0000 From: Paul Wise To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, linux-kernel@vger.kernel.org Cc: Paul Wise Subject: [PATCH 3/3] dm raid/raid1: enable discard support when any devices support discard Date: Sun, 19 Apr 2020 15:30:26 +0800 Message-Id: <20200419073026.197967-4-pabs3@bonedaddy.net> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200419073026.197967-1-pabs3@bonedaddy.net> References: <20200419073026.197967-1-pabs3@bonedaddy.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will allow fstrim to work on filesystems on dm RAID arrays with both HDDs and SSDs or dm raid SSD arrays with varying discard support, which should increase the lifetime of the SSDs that support discard. This makes dm raid and dm raid1 (mirroring) consistent with md raid, which supports discard when only some of the devices support discard. The existing code prevents this from being enabled with RAID 4/5/6, which require more certainty about the behaviour of underlying devices after a discard has been issued and processed. Simply enable discard and return from the configure_discard_support function when any of the underlying devices has support for discards, since there are now no other checks in the device check loop. Mixed discard support for md RAID types was added in these commits: commit c83057a1f4f9 ("md: raid 0 supports TRIM") commit 2ff8cc2c6d4e ("md: raid 1 supports TRIM") commit 532a2a3fba8d ("md: raid 10 supports TRIM") commit f1cad2b68ed1 ("md: linear supports TRIM") Signed-off-by: Paul Wise --- drivers/md/dm-raid.c | 8 ++++++-- drivers/md/dm-raid1.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 0f95e50e62a8..63f5d05021a9 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -2962,11 +2962,15 @@ static void configure_discard_support(struct raid_set *rs) continue; q = bdev_get_queue(rs->dev[i].rdev.bdev); - if (!q || !blk_queue_discard(q)) + if (q && blk_queue_discard(q)) { + ti->discard_support = DM_DISCARD_ANY_DEVS; + ti->num_discard_bios = 1; return; + } } - ti->num_discard_bios = 1; + ti->discard_support = DM_DISCARD_ALL_DEVS; + ti->num_discard_bios = 0; } /* diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 089aed57e083..2bfed681dd3f 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -1114,6 +1114,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) goto err_free_context; ti->num_flush_bios = 1; + ti->discard_support = DM_DISCARD_ANY_DEVS; ti->num_discard_bios = 1; ti->per_io_data_size = sizeof(struct dm_raid1_bio_record); -- 2.26.1