From owner-svn-src-all@freebsd.org Thu Jan 25 21:38:10 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 92F83ECF113; Thu, 25 Jan 2018 21:38:10 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F1DF72D46; Thu, 25 Jan 2018 21:38:10 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 29FC612809; Thu, 25 Jan 2018 21:38:10 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0PLcAL1098275; Thu, 25 Jan 2018 21:38:10 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0PLcA7t098274; Thu, 25 Jan 2018 21:38:10 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201801252138.w0PLcA7t098274@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 25 Jan 2018 21:38:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328414 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 328414 X-SVN-Commit-Repository: base 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.25 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, 25 Jan 2018 21:38:10 -0000 Author: imp Date: Thu Jan 25 21:38:09 2018 New Revision: 328414 URL: https://svnweb.freebsd.org/changeset/base/328414 Log: When devices are invalidated, there's some cases where ccbs for that device still wind up in xpt_done after the path has been invalidated. Since we don't always need sim or devq, add some guard rails to only fail if we have to use them. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D14040 Modified: head/sys/cam/cam_xpt.c Modified: head/sys/cam/cam_xpt.c ============================================================================== --- head/sys/cam/cam_xpt.c Thu Jan 25 21:36:26 2018 (r328413) +++ head/sys/cam/cam_xpt.c Thu Jan 25 21:38:09 2018 (r328414) @@ -5374,8 +5374,8 @@ xpt_path_mtx(struct cam_path *path) static void xpt_done_process(struct ccb_hdr *ccb_h) { - struct cam_sim *sim; - struct cam_devq *devq; + struct cam_sim *sim = NULL; + struct cam_devq *devq = NULL; struct mtx *mtx = NULL; #if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING) @@ -5418,9 +5418,15 @@ xpt_done_process(struct ccb_hdr *ccb_h) mtx_unlock(&xsoftc.xpt_highpower_lock); } - sim = ccb_h->path->bus->sim; + /* + * Insulate against a race where the periph is destroyed + * but CCBs are still not all processed. + */ + if (ccb_h->path->bus) + sim = ccb_h->path->bus->sim; if (ccb_h->status & CAM_RELEASE_SIMQ) { + KASSERT(sim, ("sim missing for CAM_RELEASE_SIMQ request")); xpt_release_simq(sim, /*run_queue*/FALSE); ccb_h->status &= ~CAM_RELEASE_SIMQ; } @@ -5431,9 +5437,12 @@ xpt_done_process(struct ccb_hdr *ccb_h) ccb_h->status &= ~CAM_DEV_QFRZN; } - devq = sim->devq; if ((ccb_h->func_code & XPT_FC_USER_CCB) == 0) { struct cam_ed *dev = ccb_h->path->device; + + if (sim) + devq = sim->devq; + KASSERT(devq, ("sim missing for XPT_FC_USER_CCB request")); mtx_lock(&devq->send_mtx); devq->send_active--;