The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=d04083d52b16893c7346ae4261ed52bf23501282
commit d04083d52b16893c7346ae4261ed52bf23501282 Author: Warner Losh <[email protected]> AuthorDate: 2026-09-11 05:13:08 +0000 Commit: Warner Losh <[email protected]> CommitDate: 2026-09-11 05:13:08 +0000 cam: Add devctl message for invalidation of a periph. Report serial number, if available, otherwise report the path of the device invalidated. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D58527 --- sbin/devd/devd.conf.5 | 4 +++- sys/cam/cam_periph.c | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5 index 7fa0ecd92b72..26a1136c42a0 100644 --- a/sbin/devd/devd.conf.5 +++ b/sbin/devd/devd.conf.5 @@ -38,7 +38,7 @@ .\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS .\" SOFTWARE. .\" -.Dd February 26, 2026 +.Dd July 28, 2026 .Dt DEVD.CONF 5 .Os .Sh NAME @@ -362,6 +362,8 @@ system. Events related to peripheral devices. .It Li CAM Ta Li periph Ta Li error Ta Generic errors. +.It Li CAM Ta Li periph Ta Li invalidate Ta +Peripheral invalidation. .It Li CAM Ta Li periph Ta Li timeout Ta Command timeouts. .El diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index e34971a8e4ff..e2672fbff7c7 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -667,6 +667,17 @@ camperiphunit(struct periph_driver *p_drv, path_id_t pathid, return (unit); } +static void +cam_periph_invalidate_devctl(struct cam_periph *periph) +{ + struct sbuf sb; + char *sbmsg; + + sbmsg = cam_periph_devctl_sb_init(&sb, periph); + if (sbmsg != NULL) + cam_periph_devctl_sb_fini(&sb, sbmsg, "invalidate"); +} + void cam_periph_invalidate(struct cam_periph *periph) { @@ -680,6 +691,8 @@ cam_periph_invalidate(struct cam_periph *periph) return; CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("Periph invalidated\n")); + if (!rebooting) + cam_periph_invalidate_devctl(periph); if ((periph->flags & CAM_PERIPH_ANNOUNCED) && !rebooting) { struct sbuf sb; char buffer[160]; @@ -2135,14 +2148,20 @@ cam_periph_devctl_sb_init(struct sbuf *sb, struct cam_periph *periph) sbuf_printf(sb, "device=%s%d ", periph->periph_name, periph->unit_number); - sbuf_cat(sb, "serial=\""); if ((cgd = (struct ccb_getdev *)xpt_alloc_ccb_nowait()) != NULL) { xpt_gdev_type(cgd, periph->path); - if (cgd->ccb_h.status == CAM_REQ_CMP) + if (cgd->ccb_h.status == CAM_REQ_CMP && + cgd->serial_num_len > 0) { + sbuf_cat(sb, "serial=\""); sbuf_bcat(sb, cgd->serial_num, cgd->serial_num_len); + sbuf_cat(sb, "\" "); + } else { + sbuf_cat(sb, "path=\""); + xpt_path_sbuf(periph->path, sb); + sbuf_cat(sb, "\" "); + } xpt_free_ccb((union ccb *)cgd); } - sbuf_cat(sb, "\" "); return (sbmsg); }
