Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Jun 2006 05:37:19 GMT
From:      Scott Long <scottl@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 99400 for review
Message-ID:  <200606170537.k5H5bJu0097109@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=99400

Change 99400 by scottl@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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606170537.k5H5bJu0097109>