Received: by 10.223.185.116 with SMTP id b49csp4528870wrg; Mon, 26 Feb 2018 20:43:29 -0800 (PST) X-Google-Smtp-Source: AH8x224o4kR7BDDnH68h5FRU+GOZEr3RQ3PgwLLOgQR8T+6/8S5M9x7HIAcYmHOAcCfZLSD1sE1u X-Received: by 2002:a17:902:8b88:: with SMTP id ay8-v6mr13048257plb.197.1519706608952; Mon, 26 Feb 2018 20:43:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519706608; cv=none; d=google.com; s=arc-20160816; b=KDe6vLXJwNgUjPkKwv4WLZl4Z9UL+BFL0g/qrcABxNguJFSP6hBswb2HiGJ7iK0b9t k4tp2mCYoRJJD4wZtSthn8+SJ5bPPZbHy7MRG3Fz0IjhGGy6eQu4D8mgYmTAzIK+BB3r NAoA/JAGOCvd6ahrnsCPnO04slke3chqjoDY4ako0EF4OkeDf95EyscjRb2h1XvXUPPT W5XBhBcm66HelgtG9YC3JzRKklcrND4ZL55j/jWPnas53G6IoNQVV9J9s3cR3uWKRV51 qYOsltNaudFnQNifopIBvdrQAf5RDf3NaeZQWZ07VjFSVIW4FmkHnVH5iZGIceE4nIS5 BfrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=0lt1hG/L98rRFyHdvEBZdR9Tx1AznfsEJOGteGMTmdA=; b=jMXPxJbEPGDXPImJP3zr422VvL0kRNDfh11nlQL+nbel47YG5TYbu7uZWax3Qnmv5Q dS8C4L3ZI5AEKFVFfo4iit78EqR4eqlQVL6QIrq7/l/fqOKRjYUourgL3pOIlj7o4owB R1RGu66A2mey0YLYzVCcO5vaMAkGPJ1k99Z68Zae3KWNBukDJQyzIJN6la0v5OFhtIEP nRTq78Rfx6ckl5fn3aUm6sbqozQR7dZ6ZzV4dhwFeRbfkSWPk+G90V9PryqDVrG1h69V kq8zlqpljae+tae6chQrufMJwk8BE0jXyrJJ2Eo4+VL14yNeE0iDR7yeIcIk2DMR0Svy 5GGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Cb1eUYJq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay4-v6si7308915plb.443.2018.02.26.20.43.14; Mon, 26 Feb 2018 20:43:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Cb1eUYJq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751836AbeB0Emg (ORCPT + 99 others); Mon, 26 Feb 2018 23:42:36 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:33094 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbeB0Eme (ORCPT ); Mon, 26 Feb 2018 23:42:34 -0500 Received: by mail-io0-f194.google.com with SMTP id f1so5869855iob.0 for ; Mon, 26 Feb 2018 20:42:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0lt1hG/L98rRFyHdvEBZdR9Tx1AznfsEJOGteGMTmdA=; b=Cb1eUYJqXYQgg1Yf/Q5GiJOB9gc2+YDCbvJGTx12JFwThxv4qSQCBr5ZByrJ2lbjgU /rwILhZweLNRW0RTZlMe6aL1HNxUG5HUWLCC23hj7OcST6rFkS3y7na/VFcxpBPlpxQv B3kppaTRqbsPKJVmjQ4edRUyoI3eGzopLA1jeGGwdbN6j91ieglz8rirw/KoJIa4aazc NkCN8HfgKqZ+f8WZfDVTalGI+ql0C88NWj6tDEd9nXcnfmw6rSBQ2iQBzZzZ7Vqnik2f vNeYOrSGVNjbt/U6Gzemvm6wGEjgd5senqlCwI2PaUyXzz2N7GCQ84LbuZqUYyMVz1l/ UiEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0lt1hG/L98rRFyHdvEBZdR9Tx1AznfsEJOGteGMTmdA=; b=SHtEPouZzeMq8spj8hrL/nam8As9Y8dJwjRMyCJi6G58bKW4+re853MzPZge+8wOep /znTR2oq51JezhJ9VFNu2qgm/cRlsB9RwJx2jjff+su+DV9oK1CWD5ygkp+FD+D+XG0/ m+Yn61jgn+SaeI+wAabvCtyieo5A9coQp8rvAdfXceEjeRKWBjL1U21lzRnokPAfQqAW ybDPtNLEWh7+eXK6mAaaOxGhYJN744P6igHRxwXcZ9DAGPuudWN9peMLkTbK5VHHgA9E zyhW8BZ1+p8tcFvxNP71CYr2uyMvISXIWYMXdIQ+UPXR5fOyaG/FBqN0TgqG4PMKV/fc i/5A== X-Gm-Message-State: APf1xPDmpXbUD8PRrYB2Pt6Ew/IQBM47Rzd5wTXUosVQR8BFwfNxVgmn bOBJwVMClTZy8jrAZF4n/D3ChO82X9HbCLxIF+Q= X-Received: by 10.107.7.153 with SMTP id g25mr14377439ioi.271.1519706553764; Mon, 26 Feb 2018 20:42:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.207.19 with HTTP; Mon, 26 Feb 2018 20:42:33 -0800 (PST) In-Reply-To: <20180226162440.GB10832@localhost.localdomain> References: <20180226085123.26120-1-baegjae@gmail.com> <20180226162440.GB10832@localhost.localdomain> From: Baegjae Sung Date: Tue, 27 Feb 2018 13:42:33 +0900 Message-ID: Subject: Re: [PATCH] nvme-multipath: fix sysfs dangerously created links To: Keith Busch Cc: axboe@fb.com, hch@lst.de, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-02-27 1:24 GMT+09:00 Keith Busch : > On Mon, Feb 26, 2018 at 05:51:23PM +0900, baegjae@gmail.com wrote: >> From: Baegjae Sung >> >> If multipathing is enabled, each NVMe subsystem creates a head >> namespace (e.g., nvme0n1) and multiple private namespaces >> (e.g., nvme0c0n1 and nvme0c1n1) in sysfs. When creating links for >> private namespaces, links of head namespace are used, so the >> namespace creation order must be followed (e.g., nvme0n1 -> >> nvme0c1n1). If the order is not followed, links of sysfs will be >> incomplete or kernel panic will occur. >> >> The kernel panic was: >> kernel BUG at fs/sysfs/symlink.c:27! >> Call Trace: >> nvme_mpath_add_disk_links+0x5d/0x80 [nvme_core] >> nvme_validate_ns+0x5c2/0x850 [nvme_core] >> nvme_scan_work+0x1af/0x2d0 [nvme_core] >> >> Correct order >> Context A Context B >> nvme0n1 >> nvme0c0n1 nvme0c1n1 >> >> Incorrect order >> Context A Context B >> nvme0c1n1 >> nvme0n1 >> nvme0c0n1 >> >> The function of a head namespace creation is moved to maintain the >> correct order. We verified the code with or without multipathing >> using three vendors of dual-port NVMe SSDs. >> >> Signed-off-by: Baegjae Sung > > Thanks, I see what you mean on the potential ordering problem here. > Calling nvme_mpath_add_disk, though, before the 'head' has any namespace > paths available looks like you'll get a lot of 'no path available' > warnings during the bring-up. It should resolve itself shortly after, > but the warnings will be a bit alarming, right? Thanks for reply. I agree what you concern about temporary 'no path available' warnings. That was why nvme_mpath_add_disk and nvme_mpath_add_disk_links were coded together. I will send you a new patch that reflects your concerns. > >> --- >> drivers/nvme/host/core.c | 12 +++--------- >> 1 file changed, 3 insertions(+), 9 deletions(-) >> >> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c >> index 0fe7ea35c221..28777b7352a5 100644 >> --- a/drivers/nvme/host/core.c >> +++ b/drivers/nvme/host/core.c >> @@ -2844,7 +2844,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, >> } >> >> static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, >> - struct nvme_id_ns *id, bool *new) >> + struct nvme_id_ns *id) >> { >> struct nvme_ctrl *ctrl = ns->ctrl; >> bool is_shared = id->nmic & (1 << 0); >> @@ -2860,8 +2860,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, >> ret = PTR_ERR(head); >> goto out_unlock; >> } >> - >> - *new = true; >> + nvme_mpath_add_disk(head); >> } else { >> struct nvme_ns_ids ids; >> >> @@ -2873,8 +2872,6 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, >> ret = -EINVAL; >> goto out_unlock; >> } >> - >> - *new = false; >> } >> >> list_add_tail(&ns->siblings, &head->list); >> @@ -2945,7 +2942,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) >> struct nvme_id_ns *id; >> char disk_name[DISK_NAME_LEN]; >> int node = dev_to_node(ctrl->dev), flags = GENHD_FL_EXT_DEVT; >> - bool new = true; >> >> ns = kzalloc_node(sizeof(*ns), GFP_KERNEL, node); >> if (!ns) >> @@ -2971,7 +2967,7 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) >> if (id->ncap == 0) >> goto out_free_id; >> >> - if (nvme_init_ns_head(ns, nsid, id, &new)) >> + if (nvme_init_ns_head(ns, nsid, id)) >> goto out_free_id; >> nvme_setup_streams_ns(ctrl, ns); >> >> @@ -3037,8 +3033,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) >> pr_warn("%s: failed to register lightnvm sysfs group for identification\n", >> ns->disk->disk_name); >> >> - if (new) >> - nvme_mpath_add_disk(ns->head); >> nvme_mpath_add_disk_links(ns); >> return; >> out_unlink_ns: >> -- >> 2.16.2 >>