From owner-svn-src-head@FreeBSD.ORG Tue Dec 16 17:01:53 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3B92F1065692; Tue, 16 Dec 2008 17:01:53 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2963A8FC08; Tue, 16 Dec 2008 17:01:53 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBGH1rPr042884; Tue, 16 Dec 2008 17:01:53 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBGH1qTT042881; Tue, 16 Dec 2008 17:01:52 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <200812161701.mBGH1qTT042881@svn.freebsd.org> From: Edward Tomasz Napierala Date: Tue, 16 Dec 2008 17:01:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186186 - in head/sys/cam: . scsi X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Dec 2008 17:01:53 -0000 Author: trasz Date: Tue Dec 16 17:01:52 2008 New Revision: 186186 URL: http://svn.freebsd.org/changeset/base/186186 Log: Fix locking in periph drivers - don't try to unlock periph that was already deallocated. Reviewed by: scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation Modified: head/sys/cam/cam_periph.c head/sys/cam/cam_xpt.c head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Tue Dec 16 16:57:33 2008 (r186185) +++ head/sys/cam/cam_periph.c Tue Dec 16 17:01:52 2008 (r186186) @@ -311,8 +311,6 @@ cam_periph_hold(struct cam_periph *perip struct mtx *mtx; int error; - mtx_assert(periph->sim->mtx, MA_OWNED); - /* * Increment the reference count on the peripheral * while we wait for our lock attempt to succeed @@ -324,6 +322,8 @@ cam_periph_hold(struct cam_periph *perip return (ENXIO); mtx = periph->sim->mtx; + mtx_assert(mtx, MA_OWNED); + if (mtx == &Giant) mtx = NULL; Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Tue Dec 16 16:57:33 2008 (r186185) +++ head/sys/cam/cam_xpt.c Tue Dec 16 17:01:52 2008 (r186186) @@ -1595,7 +1595,7 @@ xpt_remove_periph(struct cam_periph *per { struct cam_ed *device; - mtx_assert(periph->sim->mtx, MA_OWNED); + cam_periph_lock(periph); device = periph->path->device; @@ -1615,6 +1615,7 @@ xpt_remove_periph(struct cam_periph *per mtx_lock(&xsoftc.xpt_topo_lock); xsoftc.xpt_generation++; mtx_unlock(&xsoftc.xpt_topo_lock); + cam_periph_unlock(periph); } Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Tue Dec 16 16:57:33 2008 (r186185) +++ head/sys/cam/scsi/scsi_da.c Tue Dec 16 17:01:52 2008 (r186186) @@ -772,8 +772,8 @@ daclose(struct disk *dp) softc->flags &= ~DA_FLAG_OPEN; cam_periph_unhold(periph); - cam_periph_release(periph); cam_periph_unlock(periph); + cam_periph_release(periph); return (0); } @@ -995,10 +995,8 @@ dacleanup(struct cam_periph *periph) xpt_print(periph->path, "can't remove sysctl context\n"); } - cam_periph_unlock(periph); disk_destroy(softc->disk); callout_drain(&softc->sendordered_c); - cam_periph_lock(periph); free(softc, M_DEVBUF); }