Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2524805yba; Mon, 15 Apr 2019 13:33:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzogwUF9J7XKByHBjqS9F/5eCkuTxMaIFJe5XcWGuikdxK4lU0oRpFdeA4pwLn4PMce7+QS X-Received: by 2002:a65:500d:: with SMTP id f13mr73024587pgo.250.1555360434279; Mon, 15 Apr 2019 13:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555360434; cv=none; d=google.com; s=arc-20160816; b=ON8Xpns9gZxr2DIhDnpLYS9YZMlhSHzsp6OnAI3ukT63U1qzHuzKEVB0ImW2FCozUK FJIoBsnPwa5jcTofchk3E0GaJ1zSFvJIhh3dSkY9eAXvjRjK+AibFpoxHCYKpBqBMEd2 grItMED2rMUMy2Ia+qfYESpnnS4hWKoqcGNXNf9kfsMnmiQ+VGL90tvQwqEiN+EDWPN+ VLlZhkXc9xv8SUWg2Hre3BFfOeVmbJaCS0Ykkp+uXKnRmjGQabeEn2Y7ym7xpPHGvfNs 0vJyu+Pejv5i1ChLlVeR/avaLcCmbuM7e9f0+JCw6T+R564CfJvEbKhFSmCzA23C2LVQ sh1g== 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=1A+bPBaTL0irbSqY17lot5HvBz3uustIt803SKXt8kY=; b=IMjjLzA0Coxvmqpaoov89GJ6awlzqVkEHVZJdeWilviJR6IlfT98jDGPkohKEy8SNI ILBRkcimLPrf2rCrblLQPJENEboCYB4pA2wHtHNkOYrteWQPexrS9XUZhzzo4VhYi4dI S5CLGsg3MLZPPCwnC2tSgE5FU0qVdROFnAHMCZTRAyympzVJROSQfAFCsAQX9w7GV9o5 hLcikPNW1H+HFME04pny4vv4gO6Ld4DvwOKxIEOqeAMnD0eRJ8miGdkgmvUyqpsEywFs N+vkOX+AaDcV127vhvj5jaUMgggGqxs5YmzINnHvCJeV1szJCBfzm77hUTouzUmBu2to p0BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aVMIwCKZ; 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 62si44627013pge.445.2019.04.15.13.33.38; Mon, 15 Apr 2019 13:33:54 -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=aVMIwCKZ; 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 S1729898AbfDOT0Y (ORCPT + 99 others); Mon, 15 Apr 2019 15:26:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:37938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729601AbfDOTEp (ORCPT ); Mon, 15 Apr 2019 15:04:45 -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 7B022218EA; Mon, 15 Apr 2019 19:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355085; bh=y1JV1QDiaC70Wh0bqYFdiYtfJ8Yx9YOJ997lCY8ISMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aVMIwCKZHwq3rsgyQKXm2V2l9dGwx9HykzVQ4U5TCTVzSo3moam920pKTFkctt81J rddH/nAxW+ukx7CD+U6CpmmaZJXqz5AZKaYuBSjDm7GSneh0nC+29sk+5/qvvZtP7b PePwE5ZSDfMAFz5QWBN+x6oc/XLda/ZHa7W8wFHs= 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.14 67/69] dm table: propagate BDI_CAP_STABLE_WRITES to fix sporadic checksum errors Date: Mon, 15 Apr 2019 20:59:25 +0200 Message-Id: <20190415183736.670484314@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183726.036654568@linuxfoundation.org> References: <20190415183726.036654568@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 @@ -1789,6 +1789,36 @@ static bool dm_table_supports_discards(s 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) { @@ -1838,6 +1868,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