git: ce75bfcac9cf - main - nvme: Change namespace device name
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 01 Jun 2024 11:14:43 UTC
The branch main has been updated by chuck: URL: https://cgit.FreeBSD.org/src/commit/?id=ce75bfcac9cfe0bdd2285faea86019455c6fa7ea commit ce75bfcac9cfe0bdd2285faea86019455c6fa7ea Author: Chuck Tuffli <chuck@FreeBSD.org> AuthorDate: 2024-06-01 11:08:24 +0000 Commit: Chuck Tuffli <chuck@FreeBSD.org> CommitDate: 2024-06-01 11:14:14 +0000 nvme: Change namespace device name Changes the device name for NVMe and NVMe-oF namespaces from using "ns" to "n" to be more compatible with other operating systems. For example, a device which was previously /dev/nvme0ns1 is now /dev/nvme0n1. Preserves the existing functionality by creating alias from nvmeXnY to nvmeXnsY. Reviewed by: imp MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D45414 --- sys/dev/nvme/nvme_ctrlr.c | 4 ++-- sys/dev/nvme/nvme_ns.c | 8 ++++++-- sys/dev/nvmf/host/nvmf_ns.c | 8 ++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index d9bd1fce2864..155aedf2f31a 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -1478,8 +1478,8 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev) md_args.mda_mode = 0600; md_args.mda_unit = device_get_unit(dev); md_args.mda_si_drv1 = (void *)ctrlr; - status = make_dev_s(&md_args, &ctrlr->cdev, "nvme%d", - device_get_unit(dev)); + status = make_dev_s(&md_args, &ctrlr->cdev, "%s", + device_get_nameunit(dev)); if (status != 0) return (ENXIO); diff --git a/sys/dev/nvme/nvme_ns.c b/sys/dev/nvme/nvme_ns.c index 201cf9188c1e..b19fc8664407 100644 --- a/sys/dev/nvme/nvme_ns.c +++ b/sys/dev/nvme/nvme_ns.c @@ -604,10 +604,12 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t id, md_args.mda_unit = unit; md_args.mda_mode = 0600; md_args.mda_si_drv1 = ns; - res = make_dev_s(&md_args, &ns->cdev, "nvme%dns%d", - device_get_unit(ctrlr->dev), ns->id); + res = make_dev_s(&md_args, &ns->cdev, "%sn%d", + device_get_nameunit(ctrlr->dev), ns->id); if (res != 0) return (ENXIO); + ns->cdev->si_drv2 = make_dev_alias(ns->cdev, "%sns%d", + device_get_nameunit(ctrlr->dev), ns->id); ns->cdev->si_flags |= SI_UNMAPPED; @@ -618,6 +620,8 @@ void nvme_ns_destruct(struct nvme_namespace *ns) { + if (ns->cdev->si_drv2 != NULL) + destroy_dev(ns->cdev->si_drv2); if (ns->cdev != NULL) destroy_dev(ns->cdev); } diff --git a/sys/dev/nvmf/host/nvmf_ns.c b/sys/dev/nvmf/host/nvmf_ns.c index 3428cbadc974..30acbe815dbe 100644 --- a/sys/dev/nvmf/host/nvmf_ns.c +++ b/sys/dev/nvmf/host/nvmf_ns.c @@ -49,7 +49,7 @@ ns_printf(struct nvmf_namespace *ns, const char *fmt, ...) sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN); sbuf_set_drain(&sb, sbuf_printf_drain, NULL); - sbuf_printf(&sb, "%sns%u: ", device_get_nameunit(ns->sc->dev), + sbuf_printf(&sb, "%sn%u: ", device_get_nameunit(ns->sc->dev), ns->id); va_start(ap, fmt); @@ -371,10 +371,12 @@ nvmf_init_ns(struct nvmf_softc *sc, uint32_t id, mda.mda_gid = GID_WHEEL; mda.mda_mode = 0600; mda.mda_si_drv1 = ns; - error = make_dev_s(&mda, &ns->cdev, "%sns%u", + error = make_dev_s(&mda, &ns->cdev, "%sn%u", device_get_nameunit(sc->dev), id); if (error != 0) goto fail; + ns->cdev->si_drv2 = make_dev_alias(ns->cdev, "%sns%u", + device_get_nameunit(sc->dev), id); ns->cdev->si_flags |= SI_UNMAPPED; @@ -418,6 +420,8 @@ nvmf_destroy_ns(struct nvmf_namespace *ns) TAILQ_HEAD(, bio) bios; struct bio *bio; + if (ns->cdev->si_drv2 != NULL) + destroy_dev(ns->cdev->si_drv2); destroy_dev(ns->cdev); /*