From patchwork Mon Apr 13 08:13:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 227965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93909C2BBC7 for ; Mon, 13 Apr 2020 08:35:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6AA5020737 for ; Mon, 13 Apr 2020 08:35:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="U76uF4Th" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727987AbgDMIOB (ORCPT ); Mon, 13 Apr 2020 04:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.18]:41666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727975AbgDMIN7 (ORCPT ); Mon, 13 Apr 2020 04:13:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6771C00860B for ; Mon, 13 Apr 2020 01:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:In-Reply-To:References; bh=TeuaDVrLi4KBM05emhU233WXUFgTZo3Tvg/ab5fwH+0=; b=U76uF4ThDZsFSlRUGKqGQEZFm5 IAdjLWsWKFGufkoxmi9NryrGtrNjoAphF/C+SyDb7f7MURmkU+0gr5A4zdkJDPjGzfmi1ICaxIkZ6 XTJI60SdDbYwjzM8ciyC9VS8jjW/GxPeof6NbdL9WdMoxl77lmOHGzpoLmo4kN6VBfAd4AADtG/+P U9IwUvJfVn+Rc8ahStDpxvV9ZptMEnVpLP9t6iSRq2XviLxXPlL/Lb5lHPqpxsdnp2c4aPuEfqpRf fav/FOdddCVobBT4qCgNPtMOtnyP8NfDz64wnuzTebgSKKOWhHz68saoril+d9fz29nBwIwkyqXzn xDB/tSSA==; Received: from [2601:647:4802:9070:c866:767e:2caa:28fe] (helo=bombadil.infradead.org) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jNuE6-000313-CW; Mon, 13 Apr 2020 08:13:54 +0000 From: Sagi Grimberg To: stable@vger.kernel.org Subject: [PATCH stable 4.18+] nvme: Treat discovery subsystems as unique subsystems Date: Mon, 13 Apr 2020 01:13:49 -0700 Message-Id: <20200413081349.16278-1-sagi@grimberg.me> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: James Smart [ Upstream commit c26aa572027d438de9cc311aaebcbe972f698c24 ] Current code matches subnqn and collapses all controllers to the same subnqn to a single subsystem structure. This is good for recognizing multiple controllers for the same subsystem. But with the well-known discovery subnqn, the subsystems aren't truly the same subsystem. As such, subsystem specific rules, such as no overlap of controller id, do not apply. With today's behavior, the check for overlap of controller id can fail, preventing the new discovery controller from being created. When searching for like subsystem nqn, exclude the discovery nqn from matching. This will result in each discovery controller being attached to a unique subsystem structure. Signed-off-by: James Smart Reviewed-by: Sagi Grimberg Reviewed-by: Christoph Hellwig Reviewed-by: Max Gurtovoy Signed-off-by: Sagi Grimberg --- drivers/nvme/host/core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index fad04282148d..0545eb97d838 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2374,6 +2374,17 @@ static struct nvme_subsystem *__nvme_find_get_subsystem(const char *subsysnqn) lockdep_assert_held(&nvme_subsystems_lock); + /* + * Fail matches for discovery subsystems. This results + * in each discovery controller bound to a unique subsystem. + * This avoids issues with validating controller values + * that can only be true when there is a single unique subsystem. + * There may be multiple and completely independent entities + * that provide discovery controllers. + */ + if (!strcmp(subsysnqn, NVME_DISC_SUBSYS_NAME)) + return NULL; + list_for_each_entry(subsys, &nvme_subsystems, entry) { if (strcmp(subsys->subnqn, subsysnqn)) continue;