From patchwork Mon Apr 3 21:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9660645 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 D791E60364 for ; Mon, 3 Apr 2017 21:43:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C918028395 for ; Mon, 3 Apr 2017 21:43:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE4C028469; Mon, 3 Apr 2017 21:43:10 +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,DKIM_SIGNED, DKIM_VALID,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 3653A283F3 for ; Mon, 3 Apr 2017 21:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751646AbdDCVnJ (ORCPT ); Mon, 3 Apr 2017 17:43:09 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:36443 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751649AbdDCVnI (ORCPT ); Mon, 3 Apr 2017 17:43:08 -0400 Received: by mail-pg0-f41.google.com with SMTP id g2so130864338pge.3 for ; Mon, 03 Apr 2017 14:43:08 -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 :in-reply-to:references; bh=JZTwXXu92FQgoSgu79kbhEUBmB/AU69X5g6TEfINC2c=; b=2PX3jKmwWKP0BRRHwciujHfHmQZQ2qDO4bKl78OejEI8H0cXw6S4ebMZYSGhVVpD20 PK4MkC4/7Z9Bo/u+Cb5dlQJ084cjthi4ukjaDYpbrosp0kLWs/yKyX7iggx7u6ZbKx9h iZBtTz0/a0iXuFjLDHgCsN/Wt2iGtPeNtLJSlQLFBAwVIzpZehr3tbm1N8oIEC10FPw8 FI3GfMrpeTlwS5fAWDuGEiBrqynuNO42sQBV49lPWTGyW84GOGqLQLGL+yRc0l2oehZx dcIORQ9/lSL6JzUlMjpi46CFohHnURv1UCHvaxnK+eOSjP01bP6FwxiZd4e4RffZpAvh 8oUQ== 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:in-reply-to:references; bh=JZTwXXu92FQgoSgu79kbhEUBmB/AU69X5g6TEfINC2c=; b=mahEGJHoi2ki8379AH0YO+lhvfTSaDvzasnDUWIJphuAQtbJpjrwquHkuucMcqaDY1 F+FllE2irg0eh48K2qeSch7DSPckyDsBIbIhxlhyguTcmEDrXO3mT0uHWRsXavlSymyI w5OKkcUg0JJJEUqQMTEKeYTsfpfCW3DrNesqRHXs1wq6S1+hq7c7btLFp0nKHYeGHQoL /YNM3HeQlaKHwMY4rv7zzgCdghTfBiECRMnt5iuKzFcTEW2N2gZCpq99lBUdlX3Z4Hfq YP5S0ivPzjP7bQ+FOznkd0djJYTHULLJaGXZYHH8MQSZL11ySICP3v+/bHCw07RZ9cwr 2o8w== X-Gm-Message-State: AFeK/H1urSsYFTg73Gdz64ZbovfA7E31CgqlODCu7g74yPYGmndgrXhSk+hiKjborZ2curCo X-Received: by 10.99.149.65 with SMTP id t1mr2137383pgn.152.1491255788211; Mon, 03 Apr 2017 14:43:08 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::8:3198]) by smtp.gmail.com with ESMTPSA id w186sm27682980pgb.35.2017.04.03.14.43.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Apr 2017 14:43:07 -0700 (PDT) From: Omar Sandoval To: Jens Axboe , linux-block@vger.kernel.org Cc: kernel-team@fb.com Subject: [PATCH 4/5] blk-mq: remap queues when adding/removing hardware queues Date: Mon, 3 Apr 2017 14:42:04 -0700 Message-Id: <4ab0628bf930d80f618609caa564a3a036b6cbc0.1491254827.git.osandov@fb.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: References: In-Reply-To: References: 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") Reviewed-by: Keith Busch Signed-off-by: Omar Sandoval --- block/blk-mq.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 477951d10cc9..b49fdfde7e06 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2483,6 +2483,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 @@ -2537,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; @@ -2632,6 +2637,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);