From patchwork Fri Mar 31 18:59:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9657161 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 83FF8602BD for ; Fri, 31 Mar 2017 19:00:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7559B286D4 for ; Fri, 31 Mar 2017 19:00:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68A5B286EF; Fri, 31 Mar 2017 19:00:26 +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 DDBE3286D4 for ; Fri, 31 Mar 2017 19:00:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752975AbdCaTA0 (ORCPT ); Fri, 31 Mar 2017 15:00:26 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:35459 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750707AbdCaTAZ (ORCPT ); Fri, 31 Mar 2017 15:00:25 -0400 Received: by mail-pg0-f53.google.com with SMTP id 81so79212204pgh.2 for ; Fri, 31 Mar 2017 12:00:24 -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; bh=AVTNea/FyIC5iN1pVjPbku4Ji9gD0sEFi+x1dsBwTNg=; b=MWlPeOdEvw64IUJyvjSOuQMmGwiurIVKhDgWQEhd0JJdZsDzfxOoujDMyLvEA9YD+G n9GB//mKoUoYs8IVVNN4Ythel+2+d1c/1XACFds9k9c3MyIBn/ZL3yv0+D3oNBMXdTXU eir0rtsNISre/J91UeMbzQRyCLClM9Z2dnrdNdhm9k4c6XlIRHrWWknd/4Bd//0jWAZm ir524IPtejL7xv9RsqybS6hsO9abWXrGqZXFRNqcDFIlaS+fbr3gHNV+geL4d9HKr5P0 70vYuEsNIARpV0PhBVpIlruUG2/KfF/PJOPhRCUZcCcCizsGWGbC7azZqw9BeSXz1v3Y f5Eg== 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; bh=AVTNea/FyIC5iN1pVjPbku4Ji9gD0sEFi+x1dsBwTNg=; b=UqoCazYYtjeft98Pe6yes4Xk6hSmO99NBSOibSjPlEKZw9VhQihlhnPYsuA021hjzp ZlZlYUEWRwdiDzoHd/MU18zxj7QhFVT1NrYpIoxNGp1+ipncb3ujjnwLs3aNdQzQLQ70 16OXV3bxUyrgIJqSidmbGFuv5h0FUqdZdQdvfEv7KjEnZ8iuw8nWrJWPnZU9Zz1kFW5L UX3swPk3Fv8U3JWU/wltkLLyCoqmjblzf/NW9JDcLBDrkKME9CL/GQuEu/TKKZAoIhmx PdGb8RtCNBFM5aMGCTe6BKQ7F81jTOBB5ZG5ewgjH4/NfRz7EG7pjABjXQDHGjBZT7xA QFgA== X-Gm-Message-State: AFeK/H3E2ghMK0waavmqR9UXIMqPEYVTP6hQMpq2Ep0CxYT6NP0cVHs6ndGu9U0qR3dX5ZTH X-Received: by 10.84.168.4 with SMTP id e4mr4950982plb.138.1490986823578; Fri, 31 Mar 2017 12:00:23 -0700 (PDT) Received: from localhost.localdomain ([2601:602:8801:8110:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id 65sm11964937pfg.109.2017.03.31.12.00.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 12:00:22 -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] blk-mq: remap queues when adding/removing hardware queues Date: Fri, 31 Mar 2017 11:59:24 -0700 Message-Id: <52fb0623a8496808622c718f0f6372d37574dbe1.1490986618.git.osandov@fb.com> X-Mailer: git-send-email 2.12.1 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_queue_reinit() optionally remap queues, which we do when updating the number of hardware queues but not when hotplugging. Fixes: 4e68a011428a ("blk-mq: don't redistribute hardware queues on a CPU hotplug event") Signed-off-by: Omar Sandoval --- The only callers of blk_mq_update_nr_hw_queues() are nbd and nbd. I *think* nbd_dev_add() also wants this remap behavior. block/blk-mq.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 061fc2cc88d3..1abbf7c83193 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2343,14 +2343,27 @@ void blk_mq_free_queue(struct request_queue *q) blk_mq_exit_hw_queues(q, set, set->nr_hw_queues); } +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); +} + + /* Basically redo blk_mq_init_queue with queue frozen */ static void blk_mq_queue_reinit(struct request_queue *q, - const struct cpumask *online_mask) + const struct cpumask *online_mask, + bool remap_queues) { WARN_ON_ONCE(!atomic_read(&q->mq_freeze_depth)); blk_mq_sysfs_unregister(q); + if (remap_queues) + blk_mq_update_queue_map(q->tag_set); + /* * redo blk_mq_init_cpu_queues and blk_mq_init_hw_queues. FIXME: maybe * we should change hctx numa_node according to new topology (this @@ -2387,7 +2400,7 @@ static void blk_mq_queue_reinit_work(void) blk_mq_freeze_queue_wait(q); list_for_each_entry(q, &all_q_list, all_q_node) - blk_mq_queue_reinit(q, &cpuhp_online_new); + blk_mq_queue_reinit(q, &cpuhp_online_new, false); list_for_each_entry(q, &all_q_list, all_q_node) blk_mq_unfreeze_queue(q); @@ -2532,10 +2545,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; @@ -2629,11 +2639,12 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues) set->nr_hw_queues = nr_hw_queues; 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); + blk_mq_queue_reinit(q, cpu_online_mask, true); } 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);