From owner-svn-src-all@freebsd.org Tue Dec 19 04:13:23 2017 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 58656E832B7; Tue, 19 Dec 2017 04:13:23 +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 mx1.freebsd.org (Postfix) with ESMTPS id 2FDD43D9B; Tue, 19 Dec 2017 04:13:23 +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 vBJ4DMK7090983; Tue, 19 Dec 2017 04:13:22 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBJ4DMY9090982; Tue, 19 Dec 2017 04:13:22 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201712190413.vBJ4DMY9090982@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Tue, 19 Dec 2017 04:13:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326964 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 326964 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: Tue, 19 Dec 2017 04:13:23 -0000 Author: imp Date: Tue Dec 19 04:13:22 2017 New Revision: 326964 URL: https://svnweb.freebsd.org/changeset/base/326964 Log: When doing a dump, the scheduler is normally not running, so this changed worked to capture dumps for me. However, the test for SCHEDULER_STOPPED() isn't right. We can also call the dump routine from ddb, in which case the scheduler is still running. This leads to an assertion panic that we're sleeping when we shouldn't. Instead, use the proper test for dumping or not. This brings us in line with other places that do special things while we're doing polled I/O like this. Noticed by: pho@ Differential Revision: https://reviews.freebsd.org/D13531 Modified: head/sys/cam/cam_periph.c Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Tue Dec 19 04:06:07 2017 (r326963) +++ head/sys/cam/cam_periph.c Tue Dec 19 04:13:22 2017 (r326964) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1158,7 +1159,7 @@ cam_periph_runccb(union ccb *ccb, struct bintime *starttime; struct bintime ltime; int error; - bool sched_stopped; + bool must_poll; struct mtx *periph_mtx; struct cam_periph *periph; uint32_t timeout = 1; @@ -1182,7 +1183,13 @@ cam_periph_runccb(union ccb *ccb, devstat_start_transaction(ds, starttime); } - sched_stopped = SCHEDULER_STOPPED(); + /* + * We must poll the I/O while we're dumping. The scheduler is normally + * stopped for dumping, except when we call doadump from ddb. While the + * scheduler is running in this case, we still need to poll the I/O to + * avoid sleeping waiting for the ccb to complete. + */ + must_poll = dumping; ccb->ccb_h.cbfcnp = cam_periph_done; periph = xpt_path_periph(ccb->ccb_h.path); periph_mtx = cam_periph_mtx(periph); @@ -1193,7 +1200,7 @@ cam_periph_runccb(union ccb *ccb, * cam_periph_error can reschedule the ccb by calling xpt_action and returning * ERESTART, so we have to effect the polling in the do loop below. */ - if (sched_stopped) { + if (must_poll) { mtx_unlock(periph_mtx); timeout = xpt_poll_setup(ccb); } @@ -1204,11 +1211,11 @@ cam_periph_runccb(union ccb *ccb, } else { xpt_action(ccb); do { - if (!sched_stopped) - cam_periph_ccbwait(ccb); - else { + if (must_poll) { xpt_pollwait(ccb, timeout); timeout = ccb->ccb_h.timeout * 10; + } else { + cam_periph_ccbwait(ccb); } if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) error = 0; @@ -1220,7 +1227,7 @@ cam_periph_runccb(union ccb *ccb, } while (error == ERESTART); } - if (sched_stopped) + if (must_poll) mtx_lock(periph_mtx); if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) {