From patchwork Mon Apr 3 19:13:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9660423 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 CF0E560353 for ; Mon, 3 Apr 2017 19:13:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C366A283B9 for ; Mon, 3 Apr 2017 19:13:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B81E0284C2; Mon, 3 Apr 2017 19:13:22 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 42449283B9 for ; Mon, 3 Apr 2017 19:13:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751515AbdDCTNV (ORCPT ); Mon, 3 Apr 2017 15:13:21 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:36022 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282AbdDCTNU (ORCPT ); Mon, 3 Apr 2017 15:13:20 -0400 Received: by mail-qk0-f193.google.com with SMTP id v75so437918qkb.3 for ; Mon, 03 Apr 2017 12:13:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id; bh=wS2xdjmwH0yjV7ue14TdEdHjdwZKpGTjbSbNEsYIGJA=; b=ssMLWkJGldBl+26LQwcl2r/vwCsfHoTEjw5gGzajNXnRmfbKGh6HF6lIaT7Z/c5KaX kcWDUZDxOoH36yIqBoaZ548uYGE1dD32wggyG26kqCtw2wcs4Q7kJ5ylssd+HvxXamKy S3asdDDvskcpZ82kHtLPoVVE1s5btHPcQFcGWst1HFGAAXJMHw8GwYztZLAdwy+DcCzk B/JdWxz/78LJ0AgkPwAwkFfjl2i3c68DbEwonAnpdoEcANPGdp74jGqCgp7x29jV9wbo Qj551w6/DaNgM66+RtYBhMfwO458+dv8YDJF6kkJpis7RSWRLG0x5gL2Y5IWJU5EseeC Z12w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=wS2xdjmwH0yjV7ue14TdEdHjdwZKpGTjbSbNEsYIGJA=; b=jrvPHxmtgwa/K5woxB9BthykbrmMUJ2uRA6PwqFKvbttmxVIPSoE9bEchakqTSRSEl hdX/YbfXPti7TqK8+YDPIdSR24FE8smquL+2DlWtsPTMlUraDEjxQlp63SDtzNYBnR7S SFBGJXptKCgrXSLV6sp33b/bijHvngJhT7jMiqbpZz749F1t/2tm+G0RU/iQ6e4r1sVu nQ9tghhEHTU8um1h1W1tL5tPyO2rZoVADMFW6dH8BpekFOWS+hFuzQgs+6fBhKfgyaCv 9tqPsH1rG+rmPYPCvi/07dTA4fQPMlf3+GKER/n0DX4hs7EUEbT10DU7/SsBfzcFz1XU kHaA== X-Gm-Message-State: AFeK/H3hJj0vq7+dCHlDldZXmdJmDUzqBoKcjzBW+wtc8Dp3whWY3Ysj9r/LA9WPoUIWrg== X-Received: by 10.55.215.2 with SMTP id m2mr18784772qki.135.1491246800008; Mon, 03 Apr 2017 12:13:20 -0700 (PDT) Received: from localhost (cpe-2606-A000-4381-1201-225-22FF-FEB3-E51A.dyn6.twc.com. [2606:a000:4381:1201:225:22ff:feb3:e51a]) by smtp.gmail.com with ESMTPSA id o41sm10223875qto.3.2017.04.03.12.13.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 12:13:19 -0700 (PDT) From: Josef Bacik X-Google-Original-From: Josef Bacik To: kernel-team@fb.com, axboe@kernel.dk, linux-block@vger.kernel.org Subject: [PATCH] block: allow us to change max_segments on the fly Date: Mon, 3 Apr 2017 15:13:18 -0400 Message-Id: <1491246798-1774-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 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 For things like NBD we want to be able to experiment with different sized requests going over the wire. Half of our limit is controled by max_sectors_kb, but the other half is how many bvec's we can cram into a request, which is controlled by max_segments. Changing this sysfs knob to be writeable allows us to be able to control our io limits more precisely. Signed-off-by: Josef Bacik --- block/blk-sysfs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 4585426..e7db3f8 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -116,6 +116,19 @@ static ssize_t queue_max_sectors_show(struct request_queue *q, char *page) return queue_var_show(max_sectors_kb, (page)); } +static ssize_t queue_max_segments_store(struct request_queue *q, + const char *page, size_t count) +{ + unsigned long max_segments; + ssize_t ret = queue_var_store(&max_segments, page, count); + + if (ret < 0) + return ret; + + q->limits.max_segments = (short)max_segments; + return ret; +} + static ssize_t queue_max_segments_show(struct request_queue *q, char *page) { return queue_var_show(queue_max_segments(q), (page)); @@ -527,8 +540,9 @@ static struct queue_sysfs_entry queue_max_hw_sectors_entry = { }; static struct queue_sysfs_entry queue_max_segments_entry = { - .attr = {.name = "max_segments", .mode = S_IRUGO }, + .attr = {.name = "max_segments", .mode = S_IRUGO | S_IWUSR }, .show = queue_max_segments_show, + .store = queue_max_segments_store, }; static struct queue_sysfs_entry queue_max_discard_segments_entry = {