From owner-svn-src-all@FreeBSD.ORG Sat Jun 9 07:22:51 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2A31C1065780; Sat, 9 Jun 2012 07:22:51 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0A4128FC0C; Sat, 9 Jun 2012 07:22:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q597MoXj013743; Sat, 9 Jun 2012 07:22:50 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q597MoOc013740; Sat, 9 Jun 2012 07:22:50 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201206090722.q597MoOc013740@svn.freebsd.org> From: Alexander Motin Date: Sat, 9 Jun 2012 07:22:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236781 - in stable/8/sys/cam: ata scsi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Jun 2012 07:22:51 -0000 Author: mav Date: Sat Jun 9 07:22:50 2012 New Revision: 236781 URL: http://svn.freebsd.org/changeset/base/236781 Log: MFC r236228: Plug request and references leak caused by race between invalidated probe periph destruction and new incoming probe request. This at least caused problems with SATA Port Multipliers hot-plug. Modified: stable/8/sys/cam/ata/ata_xpt.c stable/8/sys/cam/scsi/scsi_xpt.c Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/8/sys/cam/ata/ata_xpt.c Sat Jun 9 07:18:53 2012 (r236780) +++ stable/8/sys/cam/ata/ata_xpt.c Sat Jun 9 07:22:50 2012 (r236781) @@ -1220,9 +1220,9 @@ done: done_ccb->ccb_h.status = found ? CAM_REQ_CMP : CAM_REQ_CMP_ERR; xpt_done(done_ccb); } + cam_periph_invalidate(periph); cam_release_devq(periph->path, RELSIM_RELEASE_RUNLEVEL, 0, CAM_RL_XPT + 1, FALSE); - cam_periph_invalidate(periph); cam_periph_release_locked(periph); } @@ -1473,12 +1473,17 @@ ata_scan_lun(struct cam_periph *periph, } if ((old_periph = cam_periph_find(path, "aprobe")) != NULL) { - probe_softc *softc; + if ((old_periph->flags & CAM_PERIPH_INVALID) == 0) { + probe_softc *softc; - softc = (probe_softc *)old_periph->softc; - TAILQ_INSERT_TAIL(&softc->request_ccbs, &request_ccb->ccb_h, - periph_links.tqe); - softc->restart = 1; + softc = (probe_softc *)old_periph->softc; + TAILQ_INSERT_TAIL(&softc->request_ccbs, + &request_ccb->ccb_h, periph_links.tqe); + softc->restart = 1; + } else { + request_ccb->ccb_h.status = CAM_REQ_CMP_ERR; + xpt_done(request_ccb); + } } else { status = cam_periph_alloc(proberegister, NULL, probecleanup, probestart, "aprobe", Modified: stable/8/sys/cam/scsi/scsi_xpt.c ============================================================================== --- stable/8/sys/cam/scsi/scsi_xpt.c Sat Jun 9 07:18:53 2012 (r236780) +++ stable/8/sys/cam/scsi/scsi_xpt.c Sat Jun 9 07:22:50 2012 (r236781) @@ -1609,9 +1609,9 @@ probedone(struct cam_periph *periph, uni done_ccb->ccb_h.status = CAM_REQ_CMP; xpt_done(done_ccb); if (TAILQ_FIRST(&softc->request_ccbs) == NULL) { + cam_periph_invalidate(periph); cam_release_devq(periph->path, RELSIM_RELEASE_RUNLEVEL, 0, CAM_RL_XPT + 1, FALSE); - cam_periph_invalidate(periph); cam_periph_release_locked(periph); } else { probeschedule(periph); @@ -2177,11 +2177,16 @@ scsi_scan_lun(struct cam_periph *periph, } if ((old_periph = cam_periph_find(path, "probe")) != NULL) { - probe_softc *softc; + if ((old_periph->flags & CAM_PERIPH_INVALID) == 0) { + probe_softc *softc; - softc = (probe_softc *)old_periph->softc; - TAILQ_INSERT_TAIL(&softc->request_ccbs, &request_ccb->ccb_h, - periph_links.tqe); + softc = (probe_softc *)old_periph->softc; + TAILQ_INSERT_TAIL(&softc->request_ccbs, + &request_ccb->ccb_h, periph_links.tqe); + } else { + request_ccb->ccb_h.status = CAM_REQ_CMP_ERR; + xpt_done(request_ccb); + } } else { status = cam_periph_alloc(proberegister, NULL, probecleanup, probestart, "probe",