From owner-svn-src-all@FreeBSD.ORG Thu Dec 18 08:26:12 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7BB807A; Thu, 18 Dec 2014 08:26:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6716F179A; Thu, 18 Dec 2014 08:26:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBI8QCv0020144; Thu, 18 Dec 2014 08:26:12 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBI8QCbf020143; Thu, 18 Dec 2014 08:26:12 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201412180826.sBI8QCbf020143@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 18 Dec 2014 08:26:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r275882 - stable/10/sys/cam/ctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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: Thu, 18 Dec 2014 08:26:12 -0000 Author: mav Date: Thu Dec 18 08:26:11 2014 New Revision: 275882 URL: https://svnweb.freebsd.org/changeset/base/275882 Log: MFC r275365: Move ctlfe_onoffline() out of lock to let it sleep when needed. Do some more other polishing while there. Modified: stable/10/sys/cam/ctl/scsi_ctl.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/scsi_ctl.c ============================================================================== --- stable/10/sys/cam/ctl/scsi_ctl.c Thu Dec 18 08:25:00 2014 (r275881) +++ stable/10/sys/cam/ctl/scsi_ctl.c Thu Dec 18 08:26:11 2014 (r275882) @@ -622,6 +622,9 @@ ctlferegister(struct cam_periph *periph, "notify CCBs, status 0x%x\n", __func__, status); return (CAM_REQ_CMP_ERR); } + mtx_lock(&bus_softc->lun_softc_mtx); + STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, softc, links); + mtx_unlock(&bus_softc->lun_softc_mtx); return (CAM_REQ_CMP); } @@ -1573,12 +1576,7 @@ ctlfe_onoffline(void *arg, int online) printf("%s: unable to create path!\n", __func__); return; } - ccb = (union ccb *)malloc(sizeof(*ccb), M_TEMP, M_NOWAIT | M_ZERO); - if (ccb == NULL) { - printf("%s: unable to malloc CCB!\n", __func__); - xpt_free_path(path); - return; - } + ccb = xpt_alloc_ccb(); xpt_setup_ccb(&ccb->ccb_h, path, CAM_PRIORITY_NONE); /* @@ -1711,10 +1709,7 @@ ctlfe_onoffline(void *arg, int online) } xpt_free_path(path); - - free(ccb, M_TEMP); - - return; + xpt_free_ccb(ccb); } static void @@ -1740,14 +1735,7 @@ ctlfe_online(void *arg) return; } - lun_softc = malloc(sizeof(*lun_softc), M_CTLFE, - M_NOWAIT | M_ZERO); - if (lun_softc == NULL) { - xpt_print(path, "%s: unable to allocate softc for " - "wildcard periph\n", __func__); - xpt_free_path(path); - return; - } + lun_softc = malloc(sizeof(*lun_softc), M_CTLFE, M_WAITOK | M_ZERO); xpt_path_lock(path); periph = cam_periph_find(path, "ctl"); @@ -1780,14 +1768,10 @@ ctlfe_online(void *arg) "cam_periph_alloc()\n", __func__, (entry != NULL) ? entry->status_text : "Unknown", status); free(lun_softc, M_CTLFE); - } else { - mtx_lock(&bus_softc->lun_softc_mtx); - STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, lun_softc, links); - mtx_unlock(&bus_softc->lun_softc_mtx); - ctlfe_onoffline(arg, /*online*/ 1); } xpt_path_unlock(path); + ctlfe_onoffline(arg, /*online*/ 1); xpt_free_path(path); } @@ -1801,6 +1785,8 @@ ctlfe_offline(void *arg) bus_softc = (struct ctlfe_softc *)arg; + ctlfe_onoffline(arg, /*online*/ 0); + /* * Disable the wildcard LUN for this port now that we have taken * the port offline. @@ -1813,14 +1799,9 @@ ctlfe_offline(void *arg) __func__); return; } - xpt_path_lock(path); - - ctlfe_onoffline(arg, /*online*/ 0); - if ((periph = cam_periph_find(path, "ctl")) != NULL) cam_periph_invalidate(periph); - xpt_path_unlock(path); xpt_free_path(path); } @@ -1881,10 +1862,6 @@ ctlfe_lun_enable(void *arg, struct ctl_i "cam_periph_alloc()\n", __func__, (entry != NULL) ? entry->status_text : "Unknown", status); free(softc, M_CTLFE); - } else { - mtx_lock(&bus_softc->lun_softc_mtx); - STAILQ_INSERT_TAIL(&bus_softc->lun_softc_list, softc, links); - mtx_unlock(&bus_softc->lun_softc_mtx); } xpt_path_unlock(path);