From patchwork Fri Mar 31 20:43:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9657287 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 91380601D2 for ; Fri, 31 Mar 2017 20:44:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8302C286FD for ; Fri, 31 Mar 2017 20:44:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77B6628706; Fri, 31 Mar 2017 20:44: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.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 11FF5286FD for ; Fri, 31 Mar 2017 20:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932630AbdCaUos (ORCPT ); Fri, 31 Mar 2017 16:44:48 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:33353 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932204AbdCaUor (ORCPT ); Fri, 31 Mar 2017 16:44:47 -0400 Received: by mail-pg0-f44.google.com with SMTP id x125so81173981pgb.0 for ; Fri, 31 Mar 2017 13:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u1A9m9M3hdW9Kn3PasltqDejHHarJU2kLpcBwdbtiwM=; b=WLExciy9FiogNNaBAql1pEZcgsygCqZNXUF6aO1rCJsxFSyNUCjHJG4d1x5G3HRvW6 t5gIH31nWVXQVx1J+pWsU+tpTxl4WAk6VLqEcjMD7g+3SKmPjqP04qWl+pbty+3I/Pdt rb2T3CyHotuD9iv0jJoCmDYzJ5nS/aNiETaqnIwekWCJGvDv9FvhpHlVMYK9IqCuIHrM GhT1Aw6t7xQN+Jd3BLInJHRyIIeQIfLbzp/H/sr8VmY8fRzW6y7nAOSyv9HocSEAJ4C9 gqALNNuKVl6Cpde7Ppn6yW+V3NVpkFDSsR/ehKlrw4FL6yCILGY6RCYwLtQ55TJ8GQEx eTdA== 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:in-reply-to :references; bh=u1A9m9M3hdW9Kn3PasltqDejHHarJU2kLpcBwdbtiwM=; b=LAv7bgCTd65ZsnLSQSMf2X9B+wHy3O7G7ibhgtFpUbjZiN9ncgt9+GLRm55lbyHd91 RXVlbFQcmlv85Bj+V5tE4yZghLsrx79vUA/aqbym3RcuqLKb7c8+TFqM+ahxwz0rd1/e DuCdG99IOWbB7bJeo/I6Omcc+VZPr96Lm+PyBKRPNyX6y09STVcS8SPvx+ye1hdBtsQR wbvuMTYllZM4ChT4Z1GrVCADJSB94Il8WGjAmDJZhtVew/dam7j04YMiQE9YJKFEpvj2 MEA6gC+8R3/gcfauEI4Vh95w+Yolo0J+aU79K0Ib8dn9jYexUIYoWKgUs7n9kBBRByWu p5aA== X-Gm-Message-State: AFeK/H1DRDQBXd96tz/fzxEVG8RF1DSy4R2udtrbVESbxzCEgNOX3xhBZCMd3mk7Y9ROzPe8 X-Received: by 10.98.76.91 with SMTP id z88mr4462792pfa.14.1490993087130; Fri, 31 Mar 2017 13:44:47 -0700 (PDT) Received: from localhost.localdomain ([2601:602:8801:8110:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id 201sm5395696pfc.126.2017.03.31.13.44.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 13:44:46 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: Christoph Hellwig , Keith Busch , Josef Bacik , kernel-team@fb.com Subject: [PATCH v2] blk-mq: remap queues when adding/removing hardware queues Date: Fri, 31 Mar 2017 13:43:41 -0700 Message-Id: X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170331204428.GM20181@localhost.localdomain> References: <20170331204428.GM20181@localhost.localdomain> 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 From: Omar Sandoval blk_mq_update_nr_hw_queues() used to remap hardware queues, which is the behavior that drivers expect. However, commit 4e68a011428a changed blk_mq_queue_reinit() to not remap queues for the case of CPU hotplugging, inadvertently making blk_mq_update_nr_hw_queues() not remap queues as well. This breaks, for example, NBD's multi-connection mode, leaving the added hardware queues unused. Fix it by making blk_mq_update_nr_hw_queues() explicitly remap the queues. Fixes: 4e68a011428a ("blk-mq: don't redistribute hardware queues on a CPU hotplug event") Signed-off-by: Omar Sandoval --- block/blk-mq.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 061fc2cc88d3..70fa2b0d385a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2478,6 +2478,14 @@ static int blk_mq_alloc_rq_maps(struct blk_mq_tag_set *set) return 0; } +static int blk_mq_update_queue_map(struct blk_mq_tag_set *set) +{ + if (set->ops->map_queues) + return set->ops->map_queues(set); + else + return blk_mq_map_queues(set); +} + /* * Alloc a tag set to be associated with one or more request queues. * May fail with EINVAL for various error conditions. May adjust the @@ -2532,10 +2540,7 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) if (!set->mq_map) goto out_free_tags; - if (set->ops->map_queues) - ret = set->ops->map_queues(set); - else - ret = blk_mq_map_queues(set); + ret = blk_mq_update_queue_map(set); if (ret) goto out_free_mq_map; @@ -2627,6 +2632,7 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues) blk_mq_freeze_queue(q); set->nr_hw_queues = nr_hw_queues; + blk_mq_update_queue_map(set); list_for_each_entry(q, &set->tag_list, tag_set_list) { blk_mq_realloc_hw_ctxs(set, q); blk_mq_queue_reinit(q, cpu_online_mask); @@ -2634,6 +2640,7 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues) list_for_each_entry(q, &set->tag_list, tag_set_list) blk_mq_unfreeze_queue(q); + } EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues);