mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 11:25:21 +01:00
nda: AC_GETDEV_CHANGED calls media chanaged for sectorsize change
When the sector size changes, we assume it's new media. When the mediasize changes, we'll just resize the disk (we get called for both events). When neither have changed, don't call either. Some NVMe drives (but not all) post a async event on page 4 with the sector size changes via a FORMAT command. We'll notice the new media right away, rather than the next device open. As a practical effect, this just means that certain geom operations will see it sooner. Since most drive interaction goes through open, that will catch those drives that do not post this event well enough. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D55521
This commit is contained in:
1 parent
5c2186b992
commit
628d7a3270
1 file changed
+14
-8
+14
-8
@@ -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:
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user