Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp788231ybe; Wed, 4 Sep 2019 07:47:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+wbccZBuDw+e/vDlK8i+h+QtZYnwM6RAD8R+ZiooimbqWSOLbyG+KI6UaV/c8qFjzp7nL X-Received: by 2002:a17:90a:ba8a:: with SMTP id t10mr5467752pjr.142.1567608432173; Wed, 04 Sep 2019 07:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567608432; cv=none; d=google.com; s=arc-20160816; b=LGiiq9P8Kr5FExIXbla37Y3gwkAWbX9bxXNTQET8EnINMsHm7N00TimJl36IKcxvs8 4Bkap/eC6sl+SPRoYkedtGHXLAhILT+c/6bXtBxPGvlIMt0FHvCVCjUBhtC7k4Bj/LAz X+75c9XEVyzrYsGI0jvHMIZvzxJHqmZlNTjzA3SXBnnNpFMe3oJLtEqU8Wxu4sevYf76 /fKQ4zq+FL0a/2Xtm4koZhlR4Wf88hHAshGCeCwomBWAw6aD+cHJCQdhbYNHLTqDIamq KfYZae18hqrF7pICBRYshInYLrJX6VckFvwTnozrTST0MCZtg3kMl65XBHhiswM7J0mQ 8Kig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8af3Ne7z9sPaQ19NXOnYdILwhiaYKP5XDEYuOeDS8Yg=; b=g6w6Y0c+Wreacuwos26yY/aOclyIXGs0MtNInMGnayF0nnCQNQ4Bwxut/QRDKkbikO zZCjlYpIk9zo+LP5/AYe20B87jlJ9RarQejOX2v9cZoBM0C8r5FzLWmszmMxR1ncVQ/O 8J1N+hDcT6ZifmdjZ+BHehAy+RXpzE4dKhf9rK0qWb/d3Cv9/jtCSG1DnmOt/4jkLy3E 4W44puuXo326Lg2Mf3you4atHdsumjXkkobUrQIUovMaeMBlQPDJC6YaUPJVYaaPf/eJ Ap6FjaGCtreIdNApDd4MCHcy20ZQefmdlxonB4i8byLqZ6e4/zi7aLtNIxo9eJt0liaL HWJA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si350809plp.239.2019.09.04.07.46.56; Wed, 04 Sep 2019 07:47:12 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730665AbfIDOqA (ORCPT + 99 others); Wed, 4 Sep 2019 10:46:00 -0400 Received: from mga04.intel.com ([192.55.52.120]:3453 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730326AbfIDOp7 (ORCPT ); Wed, 4 Sep 2019 10:45:59 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 07:45:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,467,1559545200"; d="scan'208";a="334232146" Received: from unknown (HELO localhost.localdomain) ([10.232.112.69]) by orsmga004.jf.intel.com with ESMTP; 04 Sep 2019 07:45:58 -0700 Date: Wed, 4 Sep 2019 08:44:27 -0600 From: Keith Busch To: Christoph Hellwig Cc: Jens Axboe , Hannes Reinecke , Sagi Grimberg , "Martin K . Petersen" , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, Keith Busch , Logan Gunthorpe Subject: Re: [PATCH] nvme-core: Fix subsystem instance mismatches Message-ID: <20190904144426.GB21302@localhost.localdomain> References: <20190831000139.7662-1-logang@deltatee.com> <20190831152910.GA29439@localhost.localdomain> <33af4d94-9f6d-9baa-01fa-0f75ccee263e@deltatee.com> <20190903164620.GA20847@localhost.localdomain> <20190904060558.GA10849@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190904060558.GA10849@lst.de> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 04, 2019 at 08:05:58AM +0200, Christoph Hellwig wrote: > On Tue, Sep 03, 2019 at 10:46:20AM -0600, Keith Busch wrote: > > Could we possibly make /dev/nvmeX be a subsystem handle without causing > > trouble for anyone? This would essentially be the same thing as today > > for non-CMIC controllers with a device-per-controller and only affects > > the CMIC ones. > > A per-subsyste character device doesn't make sense, as a lot of admin > command require a specific controller. Yeah, I was hoping to provide something special for CMIC controllers so you can do path specific admin, but that looks sure to break user space. > If this really is an isue for people we'll just need to refcount the > handle allocation. That is: > > - nvme_init_ctrl allocates a new nvme_instance or so object, which > does the ida_simple_get. > - we allocate a new subsystem that reuses the handle and grabs > a reference in nvme_init_subsystem, then if we find an existing > subsystem we drop that reference again. > - last free of a ctrl or subsystem also drops a reference, with > the final free releasing the ida Let me step through an example: Ctrl A gets instance 0. Its subsystem gets the same instance, and takes ref count on it: all namespaces in this subsystem will use '0'. Ctrl B gets instance 1, and it's in the same subsystem as Ctrl A so no new subsytem is allocated. Ctrl A is disconnected, dropping its ref on instance 0, but the subsystem still has its refcount, making it unavailable. Ctrl A is reconnected, and allocates instance 2 because 0 is still in use. Now all the namespaces in this subsystem are prefixed with nvme0, but no controller exists with the same prefix. We still have inevitable naming mismatch, right?