mbox series

[V6,0/6] hw/block/nvme: support multi-path for ctrl/ns

Message ID 20210124025450.11071-1-minwoo.im.dev@gmail.com
Headers show
Series hw/block/nvme: support multi-path for ctrl/ns | expand

Message

Minwoo Im Jan. 24, 2021, 2:54 a.m. UTC
Hello,

This is sixth patch series for the support of NVMe subsystem scheme with
multi-controller and namespace sharing in a subsystem.

This version has a fix in nvme_init_ctrl() when 'cntlid' is set to the
Identify Controller data structure by making it by cpu_to_le16() as
Keith reviewed.

Here's test result with a simple 'nvme list -v' command from this model:

  -device nvme-subsys,id=subsys0 \
  -device nvme,serial=foo,id=nvme0,subsys=subsys0 \
  -device nvme,serial=bar,id=nvme1,subsys=subsys0 \
  -device nvme,serial=baz,id=nvme2,subsys=subsys0 \
  -device nvme-ns,id=ns1,drive=drv10,nsid=1,subsys=subsys0 \
  -device nvme-ns,id=ns2,drive=drv11,nsid=2,bus=nvme2 \
  \
  -device nvme,serial=qux,id=nvme3 \
  -device nvme-ns,id=ns3,drive=drv12,nsid=3,bus=nvme3 \
  \
  -device nvme-subsys,id=subsys1 \
  -device nvme,serial=quux,id=nvme4,subsys=subsys1 \
  -device nvme-ns,id=ns4,drive=drv13,nsid=1,subsys=subsys1,zoned=true \

  root@vm:~/work# nvme list -v
  NVM Express Subsystems

  Subsystem        Subsystem-NQN                                                                                    Controllers
  ---------------- ------------------------------------------------------------------------------------------------ ----------------
  nvme-subsys1     nqn.2019-08.org.qemu:subsys0                                                                     nvme0, nvme1, nvme2
  nvme-subsys3     nqn.2019-08.org.qemu:qux                                                                         nvme3
  nvme-subsys4     nqn.2019-08.org.qemu:subsys1                                                                     nvme4

  NVM Express Controllers

  Device   SN                   MN                                       FR       TxPort Address        Subsystem    Namespaces
  -------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------
  nvme0    foo                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:06.0   nvme-subsys1 nvme1c0n1
  nvme1    bar                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:07.0   nvme-subsys1 nvme1c1n1
  nvme2    baz                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:08.0   nvme-subsys1 nvme1c2n1, nvme1c2n2
  nvme3    qux                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:09.0   nvme-subsys3 nvme3n1
  nvme4    quux                 QEMU NVMe Ctrl                           1.0      pcie   0000:00:0a.0   nvme-subsys4 nvme4c4n1

  NVM Express Namespaces

  Device       NSID     Usage                      Format           Controllers
  ------------ -------- -------------------------- ---------------- ----------------
  nvme1n1      1        134.22  MB / 134.22  MB    512   B +  0 B   nvme0, nvme1, nvme2
  nvme1n2      2        268.44  MB / 268.44  MB    512   B +  0 B   nvme2
  nvme3n1      3        268.44  MB / 268.44  MB    512   B +  0 B   nvme3
  nvme4n1      1        268.44  MB / 268.44  MB    512   B +  0 B   nvme4

Thanks,

Since V5:
  - Fix endianness for 'cntlid' in Identify Controller data structure.
    (Keith)

Since V4:
  - Code clean-up to snprintf rather than duplicating it and copy.
    (Keith)
  - Documentation for 'subsys' clean-up.  (Keith)
  - Remove 'cntlid' param from nvme_init_ctrl().  (Keith)
  - Put error_propagate() in nvme_realize().  (Keith)

Since RFC V3:
  - Exclude 'deatched' scheme from this series.  This will be covered in
    the next series by covering all the ns-related admin commands
    including ZNS and ns-mgmt. (Niklas)
  - Rebased on nvme-next.
  - Remove RFC tag from this V4.

Since RFC V2:
  - Rebased on nvme-next branch with trivial patches from the previous
    version(V2) applied. (Klaus)
  - Fix enumeration type name convention with NvmeIdNs prefix. (Klaus)
  - Put 'cntlid' to NvmeCtrl instance in nvme_init_ctrl() which was
    missed in V2.
  - Added 'detached' parameter to nvme-ns device to decide whether to
    attach or not to controller(s) in the subsystem. (Klaus)
  - Implemented Identify Active Namespace ID List aprt from Identify
    Allocated Namespace ID List by removing fall-thru statement.

Since RFC V1:
  - Updated namespace sharing scheme to be based on nvme-subsys
    hierarchy.

Minwoo Im (6):
  hw/block/nvme: introduce nvme-subsys device
  hw/block/nvme: support to map controller to a subsystem
  hw/block/nvme: add CMIC enum value for Identify Controller
  hw/block/nvme: support for multi-controller in subsystem
  hw/block/nvme: add NMIC enum value for Identify Namespace
  hw/block/nvme: support for shared namespace in subsystem

 hw/block/meson.build   |   2 +-
 hw/block/nvme-ns.c     |  23 +++++++--
 hw/block/nvme-ns.h     |   7 +++
 hw/block/nvme-subsys.c | 106 +++++++++++++++++++++++++++++++++++++++++
 hw/block/nvme-subsys.h |  32 +++++++++++++
 hw/block/nvme.c        |  72 +++++++++++++++++++++++++---
 hw/block/nvme.h        |   4 ++
 include/block/nvme.h   |   8 ++++
 8 files changed, 242 insertions(+), 12 deletions(-)
 create mode 100644 hw/block/nvme-subsys.c
 create mode 100644 hw/block/nvme-subsys.h

Comments

Klaus Jensen Jan. 25, 2021, 8:29 p.m. UTC | #1
On Jan 24 11:54, Minwoo Im wrote:
> Hello,
> 
> This is sixth patch series for the support of NVMe subsystem scheme with
> multi-controller and namespace sharing in a subsystem.
> 
> This version has a fix in nvme_init_ctrl() when 'cntlid' is set to the
> Identify Controller data structure by making it by cpu_to_le16() as
> Keith reviewed.
> 
> Here's test result with a simple 'nvme list -v' command from this model:
> 
>   -device nvme-subsys,id=subsys0 \
>   -device nvme,serial=foo,id=nvme0,subsys=subsys0 \
>   -device nvme,serial=bar,id=nvme1,subsys=subsys0 \
>   -device nvme,serial=baz,id=nvme2,subsys=subsys0 \
>   -device nvme-ns,id=ns1,drive=drv10,nsid=1,subsys=subsys0 \
>   -device nvme-ns,id=ns2,drive=drv11,nsid=2,bus=nvme2 \
>   \
>   -device nvme,serial=qux,id=nvme3 \
>   -device nvme-ns,id=ns3,drive=drv12,nsid=3,bus=nvme3 \
>   \
>   -device nvme-subsys,id=subsys1 \
>   -device nvme,serial=quux,id=nvme4,subsys=subsys1 \
>   -device nvme-ns,id=ns4,drive=drv13,nsid=1,subsys=subsys1,zoned=true \
> 
>   root@vm:~/work# nvme list -v
>   NVM Express Subsystems
> 
>   Subsystem        Subsystem-NQN                                                                                    Controllers
>   ---------------- ------------------------------------------------------------------------------------------------ ----------------
>   nvme-subsys1     nqn.2019-08.org.qemu:subsys0                                                                     nvme0, nvme1, nvme2
>   nvme-subsys3     nqn.2019-08.org.qemu:qux                                                                         nvme3
>   nvme-subsys4     nqn.2019-08.org.qemu:subsys1                                                                     nvme4
> 
>   NVM Express Controllers
> 
>   Device   SN                   MN                                       FR       TxPort Address        Subsystem    Namespaces
>   -------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------
>   nvme0    foo                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:06.0   nvme-subsys1 nvme1c0n1
>   nvme1    bar                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:07.0   nvme-subsys1 nvme1c1n1
>   nvme2    baz                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:08.0   nvme-subsys1 nvme1c2n1, nvme1c2n2
>   nvme3    qux                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:09.0   nvme-subsys3 nvme3n1
>   nvme4    quux                 QEMU NVMe Ctrl                           1.0      pcie   0000:00:0a.0   nvme-subsys4 nvme4c4n1
> 
>   NVM Express Namespaces
> 
>   Device       NSID     Usage                      Format           Controllers
>   ------------ -------- -------------------------- ---------------- ----------------
>   nvme1n1      1        134.22  MB / 134.22  MB    512   B +  0 B   nvme0, nvme1, nvme2
>   nvme1n2      2        268.44  MB / 268.44  MB    512   B +  0 B   nvme2
>   nvme3n1      3        268.44  MB / 268.44  MB    512   B +  0 B   nvme3
>   nvme4n1      1        268.44  MB / 268.44  MB    512   B +  0 B   nvme4
> 
> Thanks,
> 
> Since V5:
>   - Fix endianness for 'cntlid' in Identify Controller data structure.
>     (Keith)
> 
> Since V4:
>   - Code clean-up to snprintf rather than duplicating it and copy.
>     (Keith)
>   - Documentation for 'subsys' clean-up.  (Keith)
>   - Remove 'cntlid' param from nvme_init_ctrl().  (Keith)
>   - Put error_propagate() in nvme_realize().  (Keith)
> 
> Since RFC V3:
>   - Exclude 'deatched' scheme from this series.  This will be covered in
>     the next series by covering all the ns-related admin commands
>     including ZNS and ns-mgmt. (Niklas)
>   - Rebased on nvme-next.
>   - Remove RFC tag from this V4.
> 
> Since RFC V2:
>   - Rebased on nvme-next branch with trivial patches from the previous
>     version(V2) applied. (Klaus)
>   - Fix enumeration type name convention with NvmeIdNs prefix. (Klaus)
>   - Put 'cntlid' to NvmeCtrl instance in nvme_init_ctrl() which was
>     missed in V2.
>   - Added 'detached' parameter to nvme-ns device to decide whether to
>     attach or not to controller(s) in the subsystem. (Klaus)
>   - Implemented Identify Active Namespace ID List aprt from Identify
>     Allocated Namespace ID List by removing fall-thru statement.
> 
> Since RFC V1:
>   - Updated namespace sharing scheme to be based on nvme-subsys
>     hierarchy.
> 
> Minwoo Im (6):
>   hw/block/nvme: introduce nvme-subsys device
>   hw/block/nvme: support to map controller to a subsystem
>   hw/block/nvme: add CMIC enum value for Identify Controller
>   hw/block/nvme: support for multi-controller in subsystem
>   hw/block/nvme: add NMIC enum value for Identify Namespace
>   hw/block/nvme: support for shared namespace in subsystem
> 
>  hw/block/meson.build   |   2 +-
>  hw/block/nvme-ns.c     |  23 +++++++--
>  hw/block/nvme-ns.h     |   7 +++
>  hw/block/nvme-subsys.c | 106 +++++++++++++++++++++++++++++++++++++++++
>  hw/block/nvme-subsys.h |  32 +++++++++++++
>  hw/block/nvme.c        |  72 +++++++++++++++++++++++++---
>  hw/block/nvme.h        |   4 ++
>  include/block/nvme.h   |   8 ++++
>  8 files changed, 242 insertions(+), 12 deletions(-)
>  create mode 100644 hw/block/nvme-subsys.c
>  create mode 100644 hw/block/nvme-subsys.h
> 

Thanks Minwoo! This really is great stuff.

Notwithstanding the nitpicks I've pointed out for [1/6] and [6/6] (no
need to v7 for those), take my

Tested-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
Minwoo Im Jan. 26, 2021, 12:53 a.m. UTC | #2
On 21-01-25 21:29:58, Klaus Jensen wrote:
> On Jan 24 11:54, Minwoo Im wrote:
> > Hello,
> > 
> > This is sixth patch series for the support of NVMe subsystem scheme with
> > multi-controller and namespace sharing in a subsystem.
> > 
> > This version has a fix in nvme_init_ctrl() when 'cntlid' is set to the
> > Identify Controller data structure by making it by cpu_to_le16() as
> > Keith reviewed.
> > 
> > Here's test result with a simple 'nvme list -v' command from this model:
> > 
> >   -device nvme-subsys,id=subsys0 \
> >   -device nvme,serial=foo,id=nvme0,subsys=subsys0 \
> >   -device nvme,serial=bar,id=nvme1,subsys=subsys0 \
> >   -device nvme,serial=baz,id=nvme2,subsys=subsys0 \
> >   -device nvme-ns,id=ns1,drive=drv10,nsid=1,subsys=subsys0 \
> >   -device nvme-ns,id=ns2,drive=drv11,nsid=2,bus=nvme2 \
> >   \
> >   -device nvme,serial=qux,id=nvme3 \
> >   -device nvme-ns,id=ns3,drive=drv12,nsid=3,bus=nvme3 \
> >   \
> >   -device nvme-subsys,id=subsys1 \
> >   -device nvme,serial=quux,id=nvme4,subsys=subsys1 \
> >   -device nvme-ns,id=ns4,drive=drv13,nsid=1,subsys=subsys1,zoned=true \
> > 
> >   root@vm:~/work# nvme list -v
> >   NVM Express Subsystems
> > 
> >   Subsystem        Subsystem-NQN                                                                                    Controllers
> >   ---------------- ------------------------------------------------------------------------------------------------ ----------------
> >   nvme-subsys1     nqn.2019-08.org.qemu:subsys0                                                                     nvme0, nvme1, nvme2
> >   nvme-subsys3     nqn.2019-08.org.qemu:qux                                                                         nvme3
> >   nvme-subsys4     nqn.2019-08.org.qemu:subsys1                                                                     nvme4
> > 
> >   NVM Express Controllers
> > 
> >   Device   SN                   MN                                       FR       TxPort Address        Subsystem    Namespaces
> >   -------- -------------------- ---------------------------------------- -------- ------ -------------- ------------ ----------------
> >   nvme0    foo                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:06.0   nvme-subsys1 nvme1c0n1
> >   nvme1    bar                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:07.0   nvme-subsys1 nvme1c1n1
> >   nvme2    baz                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:08.0   nvme-subsys1 nvme1c2n1, nvme1c2n2
> >   nvme3    qux                  QEMU NVMe Ctrl                           1.0      pcie   0000:00:09.0   nvme-subsys3 nvme3n1
> >   nvme4    quux                 QEMU NVMe Ctrl                           1.0      pcie   0000:00:0a.0   nvme-subsys4 nvme4c4n1
> > 
> >   NVM Express Namespaces
> > 
> >   Device       NSID     Usage                      Format           Controllers
> >   ------------ -------- -------------------------- ---------------- ----------------
> >   nvme1n1      1        134.22  MB / 134.22  MB    512   B +  0 B   nvme0, nvme1, nvme2
> >   nvme1n2      2        268.44  MB / 268.44  MB    512   B +  0 B   nvme2
> >   nvme3n1      3        268.44  MB / 268.44  MB    512   B +  0 B   nvme3
> >   nvme4n1      1        268.44  MB / 268.44  MB    512   B +  0 B   nvme4
> > 
> > Thanks,
> > 
> > Since V5:
> >   - Fix endianness for 'cntlid' in Identify Controller data structure.
> >     (Keith)
> > 
> > Since V4:
> >   - Code clean-up to snprintf rather than duplicating it and copy.
> >     (Keith)
> >   - Documentation for 'subsys' clean-up.  (Keith)
> >   - Remove 'cntlid' param from nvme_init_ctrl().  (Keith)
> >   - Put error_propagate() in nvme_realize().  (Keith)
> > 
> > Since RFC V3:
> >   - Exclude 'deatched' scheme from this series.  This will be covered in
> >     the next series by covering all the ns-related admin commands
> >     including ZNS and ns-mgmt. (Niklas)
> >   - Rebased on nvme-next.
> >   - Remove RFC tag from this V4.
> > 
> > Since RFC V2:
> >   - Rebased on nvme-next branch with trivial patches from the previous
> >     version(V2) applied. (Klaus)
> >   - Fix enumeration type name convention with NvmeIdNs prefix. (Klaus)
> >   - Put 'cntlid' to NvmeCtrl instance in nvme_init_ctrl() which was
> >     missed in V2.
> >   - Added 'detached' parameter to nvme-ns device to decide whether to
> >     attach or not to controller(s) in the subsystem. (Klaus)
> >   - Implemented Identify Active Namespace ID List aprt from Identify
> >     Allocated Namespace ID List by removing fall-thru statement.
> > 
> > Since RFC V1:
> >   - Updated namespace sharing scheme to be based on nvme-subsys
> >     hierarchy.
> > 
> > Minwoo Im (6):
> >   hw/block/nvme: introduce nvme-subsys device
> >   hw/block/nvme: support to map controller to a subsystem
> >   hw/block/nvme: add CMIC enum value for Identify Controller
> >   hw/block/nvme: support for multi-controller in subsystem
> >   hw/block/nvme: add NMIC enum value for Identify Namespace
> >   hw/block/nvme: support for shared namespace in subsystem
> > 
> >  hw/block/meson.build   |   2 +-
> >  hw/block/nvme-ns.c     |  23 +++++++--
> >  hw/block/nvme-ns.h     |   7 +++
> >  hw/block/nvme-subsys.c | 106 +++++++++++++++++++++++++++++++++++++++++
> >  hw/block/nvme-subsys.h |  32 +++++++++++++
> >  hw/block/nvme.c        |  72 +++++++++++++++++++++++++---
> >  hw/block/nvme.h        |   4 ++
> >  include/block/nvme.h   |   8 ++++
> >  8 files changed, 242 insertions(+), 12 deletions(-)
> >  create mode 100644 hw/block/nvme-subsys.c
> >  create mode 100644 hw/block/nvme-subsys.h
> > 
> 
> Thanks Minwoo! This really is great stuff.
> 
> Notwithstanding the nitpicks I've pointed out for [1/6] and [6/6] (no
> need to v7 for those), take my
> 
> Tested-by: Klaus Jensen <k.jensen@samsung.com>
> Reviewed-by: Klaus Jensen <k.jensen@samsung.com>

Thanks Klaus!
Keith Busch Jan. 26, 2021, 8:39 p.m. UTC | #3
This came out looking cleaner than I had initially expected. Thanks for
seeing this feature through!

Reviewed-by: Keith Busch <kbusch@kernel.org>
Minwoo Im Jan. 26, 2021, 9:41 p.m. UTC | #4
On 21-01-27 05:39:29, Keith Busch wrote:
> This came out looking cleaner than I had initially expected. Thanks for
> seeing this feature through!
> 
> Reviewed-by: Keith Busch <kbusch@kernel.org>

Thanks Keith for the review!
Klaus Jensen Feb. 4, 2021, 6:31 p.m. UTC | #5
On Jan 24 11:54, Minwoo Im wrote:
> 
> Minwoo Im (6):
>   hw/block/nvme: introduce nvme-subsys device
>   hw/block/nvme: support to map controller to a subsystem
>   hw/block/nvme: add CMIC enum value for Identify Controller
>   hw/block/nvme: support for multi-controller in subsystem
>   hw/block/nvme: add NMIC enum value for Identify Namespace
>   hw/block/nvme: support for shared namespace in subsystem
> 
>  hw/block/meson.build   |   2 +-
>  hw/block/nvme-ns.c     |  23 +++++++--
>  hw/block/nvme-ns.h     |   7 +++
>  hw/block/nvme-subsys.c | 106 +++++++++++++++++++++++++++++++++++++++++
>  hw/block/nvme-subsys.h |  32 +++++++++++++
>  hw/block/nvme.c        |  72 +++++++++++++++++++++++++---
>  hw/block/nvme.h        |   4 ++
>  include/block/nvme.h   |   8 ++++
>  8 files changed, 242 insertions(+), 12 deletions(-)
>  create mode 100644 hw/block/nvme-subsys.c
>  create mode 100644 hw/block/nvme-subsys.h
> 

Thanks Minwoo, this was a super awesome series.

Applied to nvme-next!
Klaus Jensen Feb. 4, 2021, 6:32 p.m. UTC | #6
On Feb  4 19:31, Klaus Jensen wrote:
> On Jan 24 11:54, Minwoo Im wrote:
> > 
> > Minwoo Im (6):
> >   hw/block/nvme: introduce nvme-subsys device
> >   hw/block/nvme: support to map controller to a subsystem
> >   hw/block/nvme: add CMIC enum value for Identify Controller
> >   hw/block/nvme: support for multi-controller in subsystem
> >   hw/block/nvme: add NMIC enum value for Identify Namespace
> >   hw/block/nvme: support for shared namespace in subsystem
> > 
> >  hw/block/meson.build   |   2 +-
> >  hw/block/nvme-ns.c     |  23 +++++++--
> >  hw/block/nvme-ns.h     |   7 +++
> >  hw/block/nvme-subsys.c | 106 +++++++++++++++++++++++++++++++++++++++++
> >  hw/block/nvme-subsys.h |  32 +++++++++++++
> >  hw/block/nvme.c        |  72 +++++++++++++++++++++++++---
> >  hw/block/nvme.h        |   4 ++
> >  include/block/nvme.h   |   8 ++++
> >  8 files changed, 242 insertions(+), 12 deletions(-)
> >  create mode 100644 hw/block/nvme-subsys.c
> >  create mode 100644 hw/block/nvme-subsys.h
> > 
> 
> Thanks Minwoo, this was a super awesome series.
> 
> Applied to nvme-next!

By the way, we are really cluttering up hw/block now, so I'm gonna
submit a patch based on the one that Philippe did to move the device
into hw/nvme.