From patchwork Tue Mar 26 19:20:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 10872137 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2ABD139A for ; Tue, 26 Mar 2019 20:12:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B915128D07 for ; Tue, 26 Mar 2019 20:12:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9FF328D31; Tue, 26 Mar 2019 20:12:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1EB0028D07 for ; Tue, 26 Mar 2019 20:12:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2FD030833C2; Tue, 26 Mar 2019 20:12:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83DB11975E; Tue, 26 Mar 2019 20:11:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 64BEF41F3D; Tue, 26 Mar 2019 20:11:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2QJKIgT024073 for ; Tue, 26 Mar 2019 15:20:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 060E160160; Tue, 26 Mar 2019 19:20:18 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E889F600C1; Tue, 26 Mar 2019 19:20:13 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 499C730944B6; Tue, 26 Mar 2019 19:19:57 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id o1so15708022wrs.13; Tue, 26 Mar 2019 12:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tcVELMKFp4IxiMIX/M4XKcsfjFYZx5YLZPdrknKOL5A=; b=onlISp6Pabfm+ShWj7I9Ilzushc5RD02k+4Tn3Nn5B+E9h9Cog7ixfcoCHcHPUy1Hl vCKv5EgGudt3ixU1jm7xyFezH58lfvfvDnuZKRo+fg6lqKeZ/QC4r0dzAC0Lf5nMkDMX 7vrgakCwvVtChT7y3pxXbgbht0PXikdF2IehmBOskyLGYx2W28RLgXJXCRHoG+Xr8XXT 4Q/Nk4fhk4MqOD+q6pvJK2RFtU5pijVbODZUMt0ionF3zFkhmMXX1Va9D5kzJyvjPGKh p7SZjFEVDozV669D2/vUZ4zxFh9yveHjGoWaJo+CtoNbi8URxv23MjlnHgEFru503eYq wrVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tcVELMKFp4IxiMIX/M4XKcsfjFYZx5YLZPdrknKOL5A=; b=Ofc3g4panWu1fQB1f/3e50gUvoEIEFulK8A0xFZ3rDmfeEFzQF5CQf4HF3BzsuIlKt tZdZ97lKsX9SMEzhlYWk04tYtS/o0E03i5yVO0YoM5Qkm0Q3/rDIcYQXXx8gRO9P2526 btHe7RLlzSIMslUwDdc5x7lmpojeGF4q1h3pG4iHOgfp67VHGq1rMvkPfiSdinL14nai CE8oyoTlBKz+leVyxSpV7/7iZnt2YRW9Yuye85IWa/P8M1H4n+30kcvskufg7ry5xoEG lrP2liXjtnsZxxhaioE3bN0b2LgPdYbVP4OfDHw0o/0/TbAmVqLDoDB/MpuRmg6BiTxX l4UA== X-Gm-Message-State: APjAAAXxxuPZpdLME+d3MOZV8FNwIfPqa13Q7JxzeS3HQkwGf0lX9QJo XGED69/KhyUju+gStjq051XapE0C X-Google-Smtp-Source: APXvYqxJA+fD/cYqxEe/sWBic5a0p1DxEVz1+gjoQTkbYQOlVuthMAgfaxJ6Ydln49WV5iC9wliung== X-Received: by 2002:adf:f5c7:: with SMTP id k7mr20008004wrp.197.1553627995780; Tue, 26 Mar 2019 12:19:55 -0700 (PDT) Received: from kwango.redhat.com (ovpn-brq.redhat.com. [213.175.37.11]) by smtp.gmail.com with ESMTPSA id c20sm25135672wre.28.2019.03.26.12.19.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Mar 2019 12:19:54 -0700 (PDT) From: Ilya Dryomov To: Mike Snitzer Date: Tue, 26 Mar 2019 20:20:58 +0100 Message-Id: <20190326192058.21844-1-idryomov@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 26 Mar 2019 19:19:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 26 Mar 2019 19:19:57 +0000 (UTC) for IP:'209.85.221.66' DOMAIN:'mail-wr1-f66.google.com' HELO:'mail-wr1-f66.google.com' FROM:'idryomov@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.101 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.221.66 mail-wr1-f66.google.com 209.85.221.66 mail-wr1-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Tue, 26 Mar 2019 16:11:54 -0400 Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org Subject: [dm-devel] [PATCH] dm table: propagate BDI_CAP_STABLE_WRITES X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Tue, 26 Mar 2019 20:12:02 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Some devices don't use blk_integrity but still want stable pages because they do their own checksumming. Examples include rbd and iSCSI when data digests are negotiated. Stacking DM (and thus LVM) on top of these devices results in sporadic checksum errors. Set BDI_CAP_STABLE_WRITES if any underlying device has it set. Signed-off-by: Ilya Dryomov --- drivers/md/dm-table.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index ba9481f1bf3c..cde3b49b2a91 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1844,6 +1844,36 @@ static bool dm_table_supports_secure_erase(struct dm_table *t) return true; } +static int device_requires_stable_pages(struct dm_target *ti, + struct dm_dev *dev, sector_t start, + sector_t len, void *data) +{ + struct request_queue *q = bdev_get_queue(dev->bdev); + + return q && bdi_cap_stable_pages_required(q->backing_dev_info); +} + +/* + * If any underlying device requires stable pages, a table must require + * them as well. Only targets that support iterate_devices are considered: + * don't want error, zero, etc to require stable pages. + */ +static bool dm_table_requires_stable_pages(struct dm_table *t) +{ + struct dm_target *ti; + unsigned i; + + for (i = 0; i < dm_table_get_num_targets(t); i++) { + ti = dm_table_get_target(t, i); + + if (ti->type->iterate_devices && + ti->type->iterate_devices(ti, device_requires_stable_pages, NULL)) + return true; + } + + return false; +} + void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, struct queue_limits *limits) { @@ -1896,6 +1926,15 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, dm_table_verify_integrity(t); + /* + * Some devices don't use blk_integrity but still want stable pages + * because they do their own checksumming. + */ + if (dm_table_requires_stable_pages(t)) + q->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; + else + q->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES; + /* * Determine whether or not this queue's I/O timings contribute * to the entropy pool, Only request-based targets use this.