Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2474992yba; Mon, 15 Apr 2019 12:24:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNCFpfJC7NYQ9RDPT/W2PzMI9a2twS4Z55K+y9ptkcZly1m+dh6mNYSeCK9Ojfedg4qZdh X-Received: by 2002:a65:5342:: with SMTP id w2mr49910852pgr.220.1555356291873; Mon, 15 Apr 2019 12:24:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555356291; cv=none; d=google.com; s=arc-20160816; b=DVsbBS5mDmxspbI1rlWqv4HX6Jxx9//VGVAWHL6Wm5ZhlwXvkkeile4lOkxeyf1GtN 3iVaJ9p9OEx0S2OnhOc21/CPAB69EiqjczIOk9ahCItjRp2WAR5G05mJnRaKwaJBbcGN IAAwgR/nXPSHYe8Xsg1YeMyFKTzaJmrv+8xinXq7sWQmgd5VMYjqKlzbVneq7aPL84js HP2ARleaboS/gGauJnmlIw4xa1S1F+H2Yk1UOcwQj52XT3dAJ+IkJpmBQt7ZK+5GibNv +ODfACEe0Onnic3ytAxB+ogmHK9lUxxDYXfFv6JUew8IGoFni9iFbw0+KOYCMwXGQMQD SJ5A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W9vFEiyd6B1ftazlMKJ5i9XiQcJhMpEUXDtoC1XYL8Y=; b=iWZbXq+WWt/6LQrC30F/n+CaORHn10303CuZJPk7nbo4drbwvqbOnwnZhOYW/mB0lA qgMGd2q5IRbAnG9VsFPJWAXEUyV0P1J5K0iJZ5GOZhjQ/+muEx3W/2h7Q88nV7VZqhAf irpxF7gh0vh902j1kiYx/fES4dp0Lr/hcAJ4qQxHrzb7kKi5DcS+s0jIWVij+SDfEk8p h7LHF26LwIzvKYSVXzUzd97PXgN8w6uy8ln0KyhAGjuwyz004qvbIETINPxy413UolW4 z91hoMMdopSqpo6Sjv/MXpBc/bLzd3aanAeg5DwyFRhdtBoWnieTAchb0uLoJPmp4Xso 3Ddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2HN0ABlA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c186si46695228pfg.160.2019.04.15.12.24.35; Mon, 15 Apr 2019 12:24:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2HN0ABlA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730733AbfDOTJ1 (ORCPT + 99 others); Mon, 15 Apr 2019 15:09:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:45162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730717AbfDOTJY (ORCPT ); Mon, 15 Apr 2019 15:09:24 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5660D20651; Mon, 15 Apr 2019 19:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355363; bh=7iSCQcHpwreHNzuzccsBH9O9JonFlPR+0nj6AE4tS8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2HN0ABlAQkcEBFudhUFBe2wC0NUIxh9KQ7FAUyAa7Y/nv1+4yuafDezf1hXovM8AR 4BOlC1GOui2glDJ9jVAM9VLvt0+7tn0jbWmnHRSRNGG4ukx2HOVQV2vuQPNcLgmvnN lgiGX5M2pFvDMZayNbV1EAv18RXxxLo1Tr29tOP4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Dryomov , Mike Snitzer Subject: [PATCH 4.19 095/101] dm table: propagate BDI_CAP_STABLE_WRITES to fix sporadic checksum errors Date: Mon, 15 Apr 2019 20:59:33 +0200 Message-Id: <20190415183745.398101293@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Dryomov commit eb40c0acdc342b815d4d03ae6abb09e80c0f2988 upstream. 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. Cc: stable@vger.kernel.org Signed-off-by: Ilya Dryomov Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-table.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1872,6 +1872,36 @@ static bool dm_table_supports_secure_era 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) { @@ -1930,6 +1960,15 @@ void dm_table_set_restrictions(struct dm 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. * Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not