Re: [PATCH] nvme-core: Fix subsystem instance mismatches

From: Christoph Hellwig
Date: Wed Sep 04 2019 - 02:06:14 EST


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.

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