From owner-p4-projects@FreeBSD.ORG Sat Jun 17 05:37:20 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BB72316A47D; Sat, 17 Jun 2006 05:37:20 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7F23116A47A for ; Sat, 17 Jun 2006 05:37:20 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 307EB43D4C for ; Sat, 17 Jun 2006 05:37:20 +0000 (GMT) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k5H5bKgl097112 for ; Sat, 17 Jun 2006 05:37:20 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k5H5bJu0097109 for perforce@freebsd.org; Sat, 17 Jun 2006 05:37:19 GMT (envelope-from scottl@freebsd.org) Date: Sat, 17 Jun 2006 05:37:19 GMT Message-Id: <200606170537.k5H5bJu0097109@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to scottl@freebsd.org using -f From: Scott Long To: Perforce Change Reviews Cc: Subject: PERFORCE change 99400 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jun 2006 05:37:21 -0000 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); }