From owner-svn-src-all@freebsd.org Thu Jan 11 03:11:42 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DC5EDE66A38; Thu, 11 Jan 2018 03:11:42 +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 B7DEE7B673; Thu, 11 Jan 2018 03:11:42 +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 0125171CC; Thu, 11 Jan 2018 03:11:42 +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 w0B3BfVe073745; Thu, 11 Jan 2018 03:11:41 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0B3BfB7073744; Thu, 11 Jan 2018 03:11:41 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201801110311.w0B3BfB7073744@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 11 Jan 2018 03:11:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327805 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 327805 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, 11 Jan 2018 03:11:43 -0000 Author: imp Date: Thu Jan 11 03:11:41 2018 New Revision: 327805 URL: https://svnweb.freebsd.org/changeset/base/327805 Log: When we crash, we'll stop the scheduler before we call the shutdown_post_sync event. For adashutdown, this causes problems because we need to poll for completion of the commands, but we're not yet officially dumping yet, so the code from r326964 assumed we could use the interrupt-driven commands rather than the polled ones. This lead to a hang. Prevent this by also checking to see if the scheduler is stopped to do the polling. Reported by: markj@ Sponsored by: Netflix Differential Review: https://reviews.freebsd.org/D13845 Modified: head/sys/cam/cam_periph.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Thu Jan 11 00:54:54 2018 (r327804) +++ head/sys/cam/cam_periph.c Thu Jan 11 03:11:41 2018 (r327805) @@ -1187,10 +1187,16 @@ cam_periph_runccb(union ccb *ccb, * scheduler is running in this case, we still need to poll the I/O to * avoid sleeping waiting for the ccb to complete. * - * XXX To avoid locking problems, dumping/polling callers must call + * A panic triggered dump stops the scheduler, any callback from the + * shutdown_post_sync event will run with the scheduler stopped, but + * before we're officially dumping. To avoid hanging in adashutdown + * initiated commands (or other similar situations), we have to test for + * either SCHEDULER_STOPPED() here as well. + * + * To avoid locking problems, dumping/polling callers must call * without a periph lock held. */ - must_poll = dumping; + must_poll = dumping || SCHEDULER_STOPPED(); ccb->ccb_h.cbfcnp = cam_periph_done; /*