Date: Wed, 19 Nov 2025 21:44:37 +0000 From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Wanpeng Qian <wanpengqian@gmail.com> Subject: git: ecfb0e51b212 - releng/15.0 - nda: React to namespace change events Message-ID: <691e3a45.33c7b.3ddda341@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch releng/15.0 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=ecfb0e51b21259a679519d666dbdb52e9b18c539 commit ecfb0e51b21259a679519d666dbdb52e9b18c539 Author: Wanpeng Qian <wanpengqian@gmail.com> AuthorDate: 2025-11-18 15:24:23 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2025-11-19 21:37:15 +0000 nda: React to namespace change events Register for AC_GETDEV_CHANGED. When we receive a namespace notification, we only create a new device if it was unconfigured. If it was configured, generate this async event. Rely on the fact that we reconstruct namespace to just get the data from the identify data and call disk_resised. Approved by: re (cperciva) Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D33032 (cherry picked from commit 86d3ec359a56d1b5d015718bd19ef4bda681a032) (cherry picked from commit 9a465b37ea17642d45597d4ee7d3283b02dfa6f0) --- sys/cam/nvme/nvme_da.c | 29 ++++++++++++++++++++--------- sys/cam/nvme/nvme_xpt.c | 2 ++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c index 330f4ca66e1e..2eb43809f4b1 100644 --- a/sys/cam/nvme/nvme_da.c +++ b/sys/cam/nvme/nvme_da.c @@ -673,12 +673,11 @@ ndasetgeom(struct nda_softc *softc, struct cam_periph *periph) } static void -ndaasync(void *callback_arg, uint32_t code, - struct cam_path *path, void *arg) +ndaasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg) { - struct cam_periph *periph; + struct cam_periph *periph = callback_arg; + struct nda_softc *softc; - periph = (struct cam_periph *)callback_arg; switch (code) { case AC_FOUND_DEVICE: { @@ -709,17 +708,29 @@ ndaasync(void *callback_arg, uint32_t code, "due to status 0x%x\n", status); break; } + case AC_GETDEV_CHANGED: + { + int error; + + softc = periph->softc; + ndasetgeom(softc, periph); + error = disk_resize(softc->disk, M_NOWAIT); + if (error != 0) { + xpt_print(periph->path, "disk_resize(9) failed, error = %d\n", error); + break; + } + break; + + } case AC_ADVINFO_CHANGED: { uintptr_t buftype; + softc = periph->softc; buftype = (uintptr_t)arg; if (buftype == CDAI_TYPE_PHYS_PATH) { - struct nda_softc *softc; - - softc = periph->softc; disk_attr_changed(softc->disk, "GEOM::physpath", - M_NOWAIT); + M_NOWAIT); } break; } @@ -997,7 +1008,7 @@ ndaregister(struct cam_periph *periph, void *arg) * Register for device going away and info about the drive * changing (though with NVMe, it can't) */ - xpt_register_async(AC_LOST_DEVICE | AC_ADVINFO_CHANGED, + xpt_register_async(AC_LOST_DEVICE | AC_ADVINFO_CHANGED | AC_GETDEV_CHANGED, ndaasync, periph, periph->path); softc->state = NDA_STATE_NORMAL; diff --git a/sys/cam/nvme/nvme_xpt.c b/sys/cam/nvme/nvme_xpt.c index f6667df07be0..c22d5fed350c 100644 --- a/sys/cam/nvme/nvme_xpt.c +++ b/sys/cam/nvme/nvme_xpt.c @@ -463,6 +463,8 @@ device_fail: if ((path->device->flags & CAM_DEV_UNCONFIGURED) == 0) done_ccb->ccb_h.func_code = XPT_GDEV_TYPE; xpt_action(done_ccb); xpt_async(AC_FOUND_DEVICE, path, done_ccb); + } else { + xpt_async(AC_GETDEV_CHANGED, path, NULL); } NVME_PROBE_SET_ACTION(softc, NVME_PROBE_DONE); break;help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?691e3a45.33c7b.3ddda341>
