Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144471323
D43525.id133114.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D43525.id133114.diff
View Options
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -262,7 +262,7 @@
static int cdgetpagesize(int page_num);
static void cdprevent(struct cam_periph *periph, int action);
static void cdmediaprobedone(struct cam_periph *periph);
-static int cdcheckmedia(struct cam_periph *periph, int do_wait);
+static int cdcheckmedia(struct cam_periph *periph, bool do_wait);
#if 0
static int cdsize(struct cam_periph *periph, uint32_t *size);
#endif
@@ -773,7 +773,7 @@
* if we don't have media, but then we don't allow anything but the
* CDIOCEJECT/CDIOCCLOSE ioctls if there is no media.
*/
- cdcheckmedia(periph, /*do_wait*/ 1);
+ cdcheckmedia(periph, /*do_wait*/ true);
CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("leaving cdopen\n"));
cam_periph_unhold(periph);
@@ -879,7 +879,7 @@
* check first. The I/O will get executed after the media check.
*/
if ((softc->flags & CD_FLAG_VALID_MEDIA) == 0)
- cdcheckmedia(periph, /*do_wait*/ 0);
+ cdcheckmedia(periph, /*do_wait*/ false);
else
xpt_schedule(periph, CAM_PRIORITY_NORMAL);
@@ -1781,7 +1781,7 @@
&& ((cmd != CDIOCCLOSE)
&& (cmd != CDIOCEJECT))
&& (IOCGROUP(cmd) == 'c')) {
- error = cdcheckmedia(periph, /*do_wait*/ 1);
+ error = cdcheckmedia(periph, /*do_wait*/ true);
if (error != 0) {
cam_periph_unhold(periph);
cam_periph_unlock(periph);
@@ -2674,6 +2674,7 @@
softc->flags &= ~CD_FLAG_MEDIA_WAIT;
wakeup(&softc->toc);
}
+ cam_periph_release_locked(periph);
}
/*
@@ -2682,7 +2683,7 @@
*/
static int
-cdcheckmedia(struct cam_periph *periph, int do_wait)
+cdcheckmedia(struct cam_periph *periph, bool do_wait)
{
struct cd_softc *softc;
int error;
@@ -2691,31 +2692,29 @@
softc = (struct cd_softc *)periph->softc;
error = 0;
- if ((do_wait != 0)
- && ((softc->flags & CD_FLAG_MEDIA_WAIT) == 0)) {
+ /* Released by cdmediaprobedone(). */
+ error = cam_periph_acquire(periph);
+ if (error != 0)
+ return (error);
+
+ if (do_wait)
softc->flags |= CD_FLAG_MEDIA_WAIT;
- }
if ((softc->flags & CD_FLAG_MEDIA_SCAN_ACT) == 0) {
softc->state = CD_STATE_MEDIA_PREVENT;
softc->flags |= CD_FLAG_MEDIA_SCAN_ACT;
xpt_schedule(periph, CAM_PRIORITY_NORMAL);
}
-
- if (do_wait == 0)
- goto bailout;
+ if (!do_wait)
+ return (0);
error = msleep(&softc->toc, cam_periph_mtx(periph), PRIBIO,"cdmedia",0);
- if (error != 0)
- goto bailout;
-
/*
* Check to see whether we have a valid size from the media. We
* may or may not have a valid TOC.
*/
- if ((softc->flags & CD_FLAG_VALID_MEDIA) == 0)
+ if (error == 0 && (softc->flags & CD_FLAG_VALID_MEDIA) == 0)
error = EINVAL;
-bailout:
return (error);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 9, 3:07 PM (12 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28591907
Default Alt Text
D43525.id133114.diff (2 KB)
Attached To
Mode
D43525: cd: Maintain a periph reference over async media checks
Attached
Detach File
Event Timeline
Log In to Comment