aboutsummaryrefslogtreecommitdiff
path: root/sys/cam
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2026-03-03 17:59:36 +0000
committerWarner Losh <imp@FreeBSD.org>2026-03-03 17:59:36 +0000
commit628d7a3270b64b6c7fae3b0c98068c670162a154 (patch)
treee15ac5a70996a510e7ef6e983160f0c6e682613f /sys/cam
parent5c2186b992546bce212dfad3e49012f4c69c2d0c (diff)
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/nvme/nvme_da.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 2e8e376f985d..a1114ffe8a44 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -432,7 +432,7 @@ ndaclose(struct disk *dp)
("nda %d outstanding commands", softc->outstanding_cmds));
cam_periph_unlock(periph);
cam_periph_release(periph);
- return (0);
+ return (0);
}
static void
@@ -760,17 +760,23 @@ ndaasync(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
}
case AC_GETDEV_CHANGED:
{
- int error;
+ off_t mediasize;
+ u_int sectorsize;
softc = periph->softc;
+ mediasize = softc->disk->d_mediasize;
+ sectorsize = softc->disk->d_sectorsize;
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;
- }
+ /*
+ * If the sectorsize changed, then it's new media. Otherwise if
+ * the media size changed, resize the existing disk. Otherwise
+ * do nothing.
+ */
+ if (sectorsize != softc->disk->d_sectorsize)
+ disk_media_changed(softc->disk, M_WAITOK);
+ else if (mediasize != softc->disk->d_mediasize)
+ disk_resize(softc->disk, M_WAITOK);
break;
-
}
case AC_ADVINFO_CHANGED:
{