Tune support for removable media in da driver:
- remove DA_FLAG_SAW_MEDIA flag, almost opposite to DA_FLAG_PACK_INVALID, using the last instead. - allow opening device with no media present, reporting zero media size and non-zero sector size, as geom/notes suggests. That allow to read device attributes and potentially do other things, not related to media.
This commit is contained in:
parent
2c79a775ed
commit
d067905faa
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=250208
@ -82,7 +82,6 @@ typedef enum {
|
|||||||
DA_FLAG_NEW_PACK = 0x002,
|
DA_FLAG_NEW_PACK = 0x002,
|
||||||
DA_FLAG_PACK_LOCKED = 0x004,
|
DA_FLAG_PACK_LOCKED = 0x004,
|
||||||
DA_FLAG_PACK_REMOVABLE = 0x008,
|
DA_FLAG_PACK_REMOVABLE = 0x008,
|
||||||
DA_FLAG_SAW_MEDIA = 0x010,
|
|
||||||
DA_FLAG_NEED_OTAG = 0x020,
|
DA_FLAG_NEED_OTAG = 0x020,
|
||||||
DA_FLAG_WENT_IDLE = 0x040,
|
DA_FLAG_WENT_IDLE = 0x040,
|
||||||
DA_FLAG_RETRY_UA = 0x080,
|
DA_FLAG_RETRY_UA = 0x080,
|
||||||
@ -1026,9 +1025,6 @@ daopen(struct disk *dp)
|
|||||||
("daopen\n"));
|
("daopen\n"));
|
||||||
|
|
||||||
softc = (struct da_softc *)periph->softc;
|
softc = (struct da_softc *)periph->softc;
|
||||||
softc->flags |= DA_FLAG_OPEN;
|
|
||||||
softc->flags &= ~DA_FLAG_PACK_INVALID;
|
|
||||||
|
|
||||||
dareprobe(periph);
|
dareprobe(periph);
|
||||||
|
|
||||||
/* Wait for the disk size update. */
|
/* Wait for the disk size update. */
|
||||||
@ -1037,25 +1033,23 @@ daopen(struct disk *dp)
|
|||||||
if (error != 0)
|
if (error != 0)
|
||||||
xpt_print(periph->path, "unable to retrieve capacity data");
|
xpt_print(periph->path, "unable to retrieve capacity data");
|
||||||
|
|
||||||
if (periph->flags & CAM_PERIPH_INVALID ||
|
if (periph->flags & CAM_PERIPH_INVALID)
|
||||||
softc->disk->d_sectorsize == 0 ||
|
|
||||||
softc->disk->d_mediasize == 0)
|
|
||||||
error = ENXIO;
|
error = ENXIO;
|
||||||
|
|
||||||
if (error == 0 && (softc->flags & DA_FLAG_PACK_REMOVABLE) != 0 &&
|
if (error == 0 && (softc->flags & DA_FLAG_PACK_REMOVABLE) != 0 &&
|
||||||
(softc->quirks & DA_Q_NO_PREVENT) == 0)
|
(softc->quirks & DA_Q_NO_PREVENT) == 0)
|
||||||
daprevent(periph, PR_PREVENT);
|
daprevent(periph, PR_PREVENT);
|
||||||
|
|
||||||
if (error == 0)
|
if (error == 0) {
|
||||||
softc->flags |= DA_FLAG_SAW_MEDIA;
|
softc->flags &= ~DA_FLAG_PACK_INVALID;
|
||||||
|
softc->flags |= DA_FLAG_OPEN;
|
||||||
|
}
|
||||||
|
|
||||||
cam_periph_unhold(periph);
|
cam_periph_unhold(periph);
|
||||||
cam_periph_unlock(periph);
|
cam_periph_unlock(periph);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0)
|
||||||
softc->flags &= ~DA_FLAG_OPEN;
|
|
||||||
cam_periph_release(periph);
|
cam_periph_release(periph);
|
||||||
}
|
|
||||||
|
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
@ -2818,9 +2812,10 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
|
|||||||
* here.
|
* here.
|
||||||
*/
|
*/
|
||||||
if (block_size == 0 && maxsector == 0) {
|
if (block_size == 0 && maxsector == 0) {
|
||||||
snprintf(announce_buf, sizeof(announce_buf),
|
block_size = 512;
|
||||||
"0MB (no media?)");
|
maxsector = -1;
|
||||||
} else if (block_size >= MAXPHYS || block_size == 0) {
|
}
|
||||||
|
if (block_size >= MAXPHYS || block_size == 0) {
|
||||||
xpt_print(periph->path,
|
xpt_print(periph->path,
|
||||||
"unsupportable block size %ju\n",
|
"unsupportable block size %ju\n",
|
||||||
(uintmax_t) block_size);
|
(uintmax_t) block_size);
|
||||||
@ -2920,6 +2915,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
|
|||||||
const char *sense_key_desc;
|
const char *sense_key_desc;
|
||||||
const char *asc_desc;
|
const char *asc_desc;
|
||||||
|
|
||||||
|
dasetgeom(periph, 512, -1, NULL, 0);
|
||||||
scsi_sense_desc(sense_key, asc, ascq,
|
scsi_sense_desc(sense_key, asc, ascq,
|
||||||
&cgd.inq_data,
|
&cgd.inq_data,
|
||||||
&sense_key_desc,
|
&sense_key_desc,
|
||||||
@ -3297,8 +3293,8 @@ daerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
|
|||||||
asc == 0x28 && ascq == 0x00)
|
asc == 0x28 && ascq == 0x00)
|
||||||
disk_media_changed(softc->disk, M_NOWAIT);
|
disk_media_changed(softc->disk, M_NOWAIT);
|
||||||
else if (sense_key == SSD_KEY_NOT_READY &&
|
else if (sense_key == SSD_KEY_NOT_READY &&
|
||||||
asc == 0x3a && (softc->flags & DA_FLAG_SAW_MEDIA)) {
|
asc == 0x3a && (softc->flags & DA_FLAG_PACK_INVALID) == 0) {
|
||||||
softc->flags &= ~DA_FLAG_SAW_MEDIA;
|
softc->flags |= DA_FLAG_PACK_INVALID;
|
||||||
disk_media_gone(softc->disk, M_NOWAIT);
|
disk_media_gone(softc->disk, M_NOWAIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user