PERFORCE change 99400 for review
Scott Long
scottl at FreeBSD.org
Sat Jun 17 05:37:21 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=99400
Change 99400 by scottl at scottl-wv1u on 2006/06/17 05:36:56
Basic locking for the pass(4) driver.
Affected files ...
.. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.c#7 edit
Differences ...
==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.c#7 (text+ko) ====
@@ -106,7 +106,7 @@
static struct cdevsw pass_cdevsw = {
.d_version = D_VERSION,
- .d_flags = D_NEEDGIANT,
+ .d_flags = 0,
.d_open = passopen,
.d_close = passclose,
.d_ioctl = passioctl,
@@ -334,8 +334,10 @@
softc = (struct pass_softc *)periph->softc;
s = splsoftcam();
+ mtx_lock(periph->sim->mtx);
if (softc->flags & PASS_FLAG_INVALID) {
splx(s);
+ mtx_unlock(periph->sim->mtx);
return(ENXIO);
}
@@ -345,6 +347,7 @@
error = securelevel_gt(td->td_ucred, 1);
if (error) {
splx(s);
+ mtx_unlock(periph->sim->mtx);
return(error);
}
@@ -353,6 +356,7 @@
*/
if (((flags & FWRITE) == 0) || ((flags & FREAD) == 0)) {
splx(s);
+ mtx_unlock(periph->sim->mtx);
return(EPERM);
}
@@ -363,11 +367,13 @@
xpt_print_path(periph->path);
printf("can't do nonblocking accesss\n");
splx(s);
+ mtx_unlock(periph->sim->mtx);
return(EINVAL);
}
if ((error = cam_periph_lock(periph, PRIBIO | PCATCH)) != 0) {
splx(s);
+ mtx_unlock(periph->sim->mtx);
return (error);
}
@@ -380,6 +386,7 @@
}
cam_periph_unlock(periph);
+ mtx_unlock(periph->sim->mtx);
return (error);
}
@@ -397,13 +404,17 @@
softc = (struct pass_softc *)periph->softc;
- if ((error = cam_periph_lock(periph, PRIBIO)) != 0)
+ mtx_lock(periph->sim->mtx);
+ if ((error = cam_periph_lock(periph, PRIBIO)) != 0) {
+ mtx_unlock(periph->sim->mtx);
return (error);
+ }
softc->flags &= ~PASS_FLAG_OPEN;
cam_periph_unlock(periph);
cam_periph_release(periph);
+ mtx_unlock(periph->sim->mtx);
return (0);
}
@@ -458,6 +469,7 @@
return(ENXIO);
softc = (struct pass_softc *)periph->softc;
+ mtx_lock(periph->sim->mtx);
error = 0;
@@ -524,6 +536,7 @@
break;
}
+ mtx_unlock(periph->sim->mtx);
return(error);
}
More information about the p4-projects
mailing list