From nobody Fri Jul 28 18:15:38 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RCG5l1JrKz4p8HZ; Fri, 28 Jul 2023 18:15:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RCG5l0hFrz4NFm; Fri, 28 Jul 2023 18:15:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690568139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mUnevsS9vjBVPYlvWStvX/bVqcCV47ytNXzX08ODBEA=; b=lQ4mMZBjWpS7LyxsX7sbSASY1ZJ/WfeoWP1GVVieLXC1ONPAHFT72QzQZIDvu3ZtxSioDR M0vDobJFHO0DHoFSwAISjk4QtdEIlteso6L6p3ssNCX0JJGE0iAFXgJv+L3wheObwEBC3+ tvVEwj7biIMikiZRhLLKVOQB+clO2Yw4Qw2xpWvIMGlhMNr7LQBVbCcS1sJr119sJ4LnG+ UrOhGA+q8OAoUVznUQcZfmsihyI4Roorbb3hYmF5emxSQlkHoUDy9zmAGhG5BTa0XaFpfo uHV4K2ObOIxXnzBKH3rbU+GNC2YQ/bpApmvUzbrxRcvUDQypOCak+WcPhSpODg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690568139; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mUnevsS9vjBVPYlvWStvX/bVqcCV47ytNXzX08ODBEA=; b=mQYe7dChfGmi6pXf8FJ+cC2D3uDzGrYU29pzs+KU9dYcDE0MfNgTNPclv7kZkwU6ir0l5Q a6bBjEuz2eIMSmYcvj3buCVxBpzNLzj3ku7gbSENPsfGNSX2+G/4ezzIeGENtgABWOiVz3 hNFh7uf/YvSUvjAg40hDn9jNvnMDdBSzQMW1jGN76nZ06jJDqfLZax9muh0vsoK/WWXmmc xLcVxLR665xJlNgstHr2R3G6FszTYo4B6iy75Z+nopM/sH7juHN6rDCePAhjWr5ZLcK/jl ImxGv4+d+QQSwWhpQl+X6D/UIcSVcmmvn2lP7jQBapTQdNsr1FgG6Kxkvs04Og== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690568139; a=rsa-sha256; cv=none; b=OOCZEmYVuSa65FyIJlbyuiBJ2u8pTLGr9hCHuIqqQidb92hElUbFAF1aJs1B2aLYMVFFyp qsUOO/jbn3wmhcDXRzg2ZE0MbYpKiItrXoGeSpi98+cWW5dTHpdHUhWD9rm1Xj4bYTtf2q KOatO7C16qk3Xt64VfJEQBzmsbNIVMxFFb6aovCbM13+IYNb0stkYUiKl4MrJI0OaufU5Z vjH7oL0EtC7tqmy7Tu4VR7U5gm7IavSvQOOfwInzx4c/1lnL12TE+QrlogqoOM25c3ZNg8 ZiXlmOU6qGwMsED+M3Z1DtnUp7pnFo5NUwHh23gABaZuOt1n9XXcp7ZMi74ocQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RCG5k6syKz11QH; Fri, 28 Jul 2023 18:15:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36SIFcwX076167; Fri, 28 Jul 2023 18:15:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36SIFc3H076166; Fri, 28 Jul 2023 18:15:38 GMT (envelope-from git) Date: Fri, 28 Jul 2023 18:15:38 GMT Message-Id: <202307281815.36SIFc3H076166@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: e474a8e24391 - main - cam: Log errors from passthru commands List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e474a8e24391b173a93c279341c452ae12d5997b Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e474a8e24391b173a93c279341c452ae12d5997b commit e474a8e24391b173a93c279341c452ae12d5997b Author: Warner Losh AuthorDate: 2023-07-28 18:11:21 +0000 Commit: Warner Losh CommitDate: 2023-07-28 18:11:21 +0000 cam: Log errors from passthru commands Since a30ecd42b8e09 we've logged almost all unexpected errors from commands. However, some passthru commands were not logged via devctl. To fix this, pass all requests through passerror (which calls cam_periph_error), but flag those requests that didn't want error recovery as SF_NO_RECOVERY, like we do for device probing. By doing this we get identical behavior to the current code, but log these errors. We have had hangs on drives that seems to show no error. Vendor analysis of the drive found an illegal command that happen to hang the drive. In verifying their analysis, we discovered that the pass through commands from things like smartctl that encountered errors or timeouts weren't logged. Sponsored by: Netflix Reviewed by: ken, mav Differential Revision: https://reviews.freebsd.org/D41167 --- sys/cam/scsi/scsi_pass.c | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c index becd8803cd2c..39ee23b956b4 100644 --- a/sys/cam/scsi/scsi_pass.c +++ b/sys/cam/scsi/scsi_pass.c @@ -183,6 +183,8 @@ static int passerror(union ccb *ccb, uint32_t cam_flags, uint32_t sense_flags); static int passsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb); +static void passflags(union ccb *ccb, uint32_t *cam_flags, + uint32_t *sense_flags); static struct periph_driver passdriver = { @@ -912,19 +914,17 @@ passdone(struct cam_periph *periph, union ccb *done_ccb) xpt_print(periph->path, "%s: called for user CCB %p\n", __func__, io_req->user_ccb_ptr); #endif - if (((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) - && (done_ccb->ccb_h.flags & CAM_PASS_ERR_RECOVER) - && ((io_req->flags & PASS_IO_ABANDONED) == 0)) { + if (((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) && + ((io_req->flags & PASS_IO_ABANDONED) == 0)) { int error; + uint32_t cam_flags, sense_flags; - error = passerror(done_ccb, CAM_RETRY_SELTO, - SF_RETRY_UA | SF_NO_PRINT); + passflags(done_ccb, &cam_flags, &sense_flags); + error = passerror(done_ccb, cam_flags, sense_flags); if (error == ERESTART) { - /* - * A retry was scheduled, so - * just return. - */ + KASSERT(((sense_flags & SF_NO_RETRY) == 0), + ("passerror returned ERESTART with no retry requested\n")); return; } } @@ -2230,10 +2230,13 @@ passsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb) * that request. Otherwise, it's up to the user to perform any * error recovery. */ - cam_periph_runccb(ccb, (ccb->ccb_h.flags & CAM_PASS_ERR_RECOVER) ? - passerror : NULL, /* cam_flags */ CAM_RETRY_SELTO, - /* sense_flags */ SF_RETRY_UA | SF_NO_PRINT, - softc->device_stats); + { + uint32_t cam_flags, sense_flags; + + passflags(ccb, &cam_flags, &sense_flags); + cam_periph_runccb(ccb, passerror, cam_flags, + sense_flags, softc->device_stats); + } cam_periph_unlock(periph); cam_periph_unmapmem(ccb, &mapinfo); @@ -2246,6 +2249,25 @@ passsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb) return(0); } +/* + * Set the cam_flags and sense_flags based on whether or not the request wants + * error recovery. In order to log errors via devctl, we need to do at least + * minimal recovery. We do this by not retrying unit attention (we let the + * requester do it, or not, if appropriate) and specifically asking for no + * recovery, like we do during device probing. + */ +static void +passflags(union ccb *ccb, uint32_t *cam_flags, uint32_t *sense_flags) +{ + if ((ccb->ccb_h.flags & CAM_PASS_ERR_RECOVER) != 0) { + *cam_flags = CAM_RETRY_SELTO; + *sense_flags = SF_RETRY_UA | SF_NO_PRINT; + } else { + *cam_flags = 0; + *sense_flags = SF_NO_RETRY | SF_NO_RECOVERY | SF_NO_PRINT; + } +} + static int passerror(union ccb *ccb, uint32_t cam_flags, uint32_t sense_flags) {