From patchwork Mon Nov 7 19:26:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Snitzer X-Patchwork-Id: 9415923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7817F6048F for ; Mon, 7 Nov 2016 19:26:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66C7B28B5E for ; Mon, 7 Nov 2016 19:26:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A3BB28BEF; Mon, 7 Nov 2016 19:26:49 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F131028B5E for ; Mon, 7 Nov 2016 19:26:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751192AbcKGT0s (ORCPT ); Mon, 7 Nov 2016 14:26:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40548 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750988AbcKGT0r (ORCPT ); Mon, 7 Nov 2016 14:26:47 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FD0680F96; Mon, 7 Nov 2016 19:26:47 +0000 (UTC) Received: from localhost (dhcp-25-188.bos.redhat.com [10.18.25.188]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA7JQkrQ008309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 7 Nov 2016 14:26:46 -0500 Date: Mon, 7 Nov 2016 14:26:47 -0500 From: Mike Snitzer To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, dm-devel@redhat.com Subject: [PATCH v2] block: disallow changing max_sectors_kb on a request stacking device Message-ID: <20161107192646.GA11572@redhat.com> References: <20161028194549.14556-1-snitzer@redhat.com> <20161107164029.GA27464@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20161107164029.GA27464@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 07 Nov 2016 19:26:47 +0000 (UTC) Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Otherwise users can easily shoot themselves in the foot by creating the situation where the top-level stacked device (e.g. DM multipath) has a larger max_sectors_kb than the underlying device(s). Which will certainly lead to IO errors due to the "over max size limit" check in blk_cloned_rq_check_limits(). This is a crude, yet effective, solution that forces the use of system software (e.g. udev rules or multipathd) to tweak max_sectors_kb of the underlying devices _before_ a layer like DM multipath is layered ontop. Signed-off-by: Mike Snitzer --- block/blk-sysfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 9cc8d7c..934f326 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -199,8 +199,12 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count) unsigned long max_sectors_kb, max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1, page_kb = 1 << (PAGE_SHIFT - 10); - ssize_t ret = queue_var_store(&max_sectors_kb, page, count); + ssize_t ret; + + if (blk_queue_stackable(q)) + return -EINVAL; + ret = queue_var_store(&max_sectors_kb, page, count); if (ret < 0) return ret;