From 9670bddac1b917ea3a748ff3769bc8728f3fc2d8 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 6 Sep 2009 14:53:51 -0700 Subject: [PATCH] USB - Avoid unnecessary reprobes. * Do not unconditionally setdiskinfo when a removable DA* device is opened. It takes time for the kernel to reprobe the drive and this seriously messes up mountroot during kernel boot or attempts to access partitions in slices (instant open + access partition). If the size hasn't changed, do not call setdiskinfo again. * This is a bad hack. A better solution (detect actual device replacement) is needed. --- sys/bus/cam/scsi/scsi_da.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/sys/bus/cam/scsi/scsi_da.c b/sys/bus/cam/scsi/scsi_da.c index 6663b4b4b6..a56aa17e98 100644 --- a/sys/bus/cam/scsi/scsi_da.c +++ b/sys/bus/cam/scsi/scsi_da.c @@ -1796,6 +1796,11 @@ dacheckmedia(struct cam_periph *periph) /* * Only reprobe on initial open and if the media is removable. + * + * NOTE: If we setdiskinfo() it will take the device probe + * a bit of time to probe the slices and partitions, + * and mess up booting. So avoid if nothing has changed. + * XXX */ if (softc->flags & DA_FLAG_OPEN) return (error); @@ -1807,13 +1812,6 @@ dacheckmedia(struct cam_periph *periph) info.d_serialno = xpt_path_serialno(periph->path); if (error == 0) { - kprintf("%s%d: open removable media: " - "%juMB (%ju %u byte sectors: %dH %dS/T %dC)\n", - periph->periph_name, periph->unit_number, - (uintmax_t)(((uintmax_t)dp->secsize * - dp->sectors) / (1024*1024)), - (uintmax_t)dp->sectors, dp->secsize, - dp->heads, dp->secs_per_track, dp->cylinders); CAM_SIM_UNLOCK(periph->sim); info.d_media_blksize = softc->params.secsize; info.d_media_blocks = softc->params.sectors; @@ -1824,7 +1822,16 @@ dacheckmedia(struct cam_periph *periph) info.d_secpercyl = softc->params.heads * softc->params.secs_per_track; info.d_serialno = xpt_path_serialno(periph->path); - disk_setdiskinfo(&softc->disk, &info); + if (info.d_media_blocks != softc->disk.d_info.d_media_blocks) { + kprintf("%s%d: open removable media: " + "%juMB (%ju %u byte sectors: %dH %dS/T %dC)\n", + periph->periph_name, periph->unit_number, + (uintmax_t)(((uintmax_t)dp->secsize * + dp->sectors) / (1024*1024)), + (uintmax_t)dp->sectors, dp->secsize, + dp->heads, dp->secs_per_track, dp->cylinders); + disk_setdiskinfo(&softc->disk, &info); + } CAM_SIM_LOCK(periph->sim); } else { kprintf("%s%d: open removable media: no media present\n", -- 2.11.4.GIT