From nobody Fri Dec 17 10:37:12 2021 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 F26F218FF31D; Fri, 17 Dec 2021 10:37:13 +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 4JFlm86g8vz4Wcd; Fri, 17 Dec 2021 10:37:12 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 93F9C1A3EE; Fri, 17 Dec 2021 10:37:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BHAbCFK092521; Fri, 17 Dec 2021 10:37:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BHAbC4o092520; Fri, 17 Dec 2021 10:37:12 GMT (envelope-from git) Date: Fri, 17 Dec 2021 10:37:12 GMT Message-Id: <202112171037.1BHAbC4o092520@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ram Kishore Vegesna Subject: git: 4821da88ab77 - stable/13 - ocs_fc: Fix CAM status reporting in ocs_fc(4) when no data is returned. 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: ram X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4821da88ab77fb603abe1c07162ea37d01730edb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639737433; 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=JaKfUXfjUOu1rj27m9C4ZmoOjUObeKl4G+IOHqbytII=; b=EB+RdxTVCUmDmSNFmNizp2x9m9uESGv9qnwRGphlypklBvYVTnvS1p6420Bhk4dxfyCqsd sIPSJl2H/JgjY7oqiZROe/6CKVWteqlsU2xvSdcO4zVlWezI/YH2HL5092zf4vpMm+t+v4 QxrYesgVAHGA4d3v/eaeFVjwTH65xiELNNCdOCDr6HC6AQxOGvwaywjvyp6tTyhCjdTHhc HUf1SUGPZEyLXNQly2QoSrQKc9mW/rlIgkkfozJypXP3p8Ym0RUlokKelfXBLknKHgfvDg daAchakSsciSqnkkG4B+eSdlN+5naC1yzcjirSESQnbcPuvmL0UeSkZ5ZkUPng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639737433; a=rsa-sha256; cv=none; b=f0SZeTn8zAVqDj6iX0NUzF14T+RXYCeCUtUzPUgFdirQDRu2napjQ34GyE5fvTPeOiOFB8 4lXC8/V2VWjsA07oMqoXUe42VzcGlDWaVSgkx+PCpmBE2JD218CUPBKkzO/F49XxdfwOZL SwsPGyt6gdHJ5xAql/JYT/WDLmovdZmxptdCRF6XYWY6af/Xq/TS7nJ4pyaR5QASXSXnsT cKBPok+2tndWBDwL34MF6IegWi+sR34/Y6+PNDKDLkRzNrpRFOGBb7g8eHPD0yY3Xo+QGp +nMvORweTWj/2J9GtXCY3RGz9TAxN5q+tYNuj37IB/VrIkYmcmyOmUQ41y3yAw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by ram: URL: https://cgit.FreeBSD.org/src/commit/?id=4821da88ab77fb603abe1c07162ea37d01730edb commit 4821da88ab77fb603abe1c07162ea37d01730edb Author: Ram Kishore Vegesna AuthorDate: 2021-09-24 09:19:49 +0000 Commit: Ram Kishore Vegesna CommitDate: 2021-12-17 10:31:05 +0000 ocs_fc: Fix CAM status reporting in ocs_fc(4) when no data is returned. In ocs_scsi_initiator_io_cb(), if the SCSI command that is getting completed had a residual equal to the transfer length, it was setting the CCB status to CAM_REQ_CMP. That breaks the expected behavior for commands like READ ATTRIBUTE. For READ ATTRIBUTE, if the first attribute requested doesn't exist, the command is supposed to return an error (Illegal Request, Invalid Field in CDB). The broken behavior for READ ATTRIBUTE caused LTFS tape formatting to fail. It looks for attribute 0x1623, and expects to see an error if the attribute isn't present. In addition, if the residual is negative (indicating an overrun), only set the CCB status to CAM_DATA_RUN_ERR if we have not already reported an error. The SCSI sense data will have more detail about what went wrong. sys/dev/ocs_fc/ocs_cam.c: In ocs_scsi_initiator_io_cb(), don't set the status to CAM_REQ_CMP if the residual is equal to the transfer length. Also, only set CAM_DATA_RUN_ERR if we didn't get SCSI status. Submitted by: ken@kdm.org Reviewed by: mav, ken (cherry picked from commit 1af49c2eeb4a05f524ed9a6657c741bc96fbaf87) --- sys/dev/ocs_fc/ocs_cam.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/dev/ocs_fc/ocs_cam.c b/sys/dev/ocs_fc/ocs_cam.c index 53b53d1b696d..82b5371b7875 100644 --- a/sys/dev/ocs_fc/ocs_cam.c +++ b/sys/dev/ocs_fc/ocs_cam.c @@ -1491,18 +1491,18 @@ static int32_t ocs_scsi_initiator_io_cb(ocs_io_t *io, if (scsi_status == OCS_SCSI_STATUS_CHECK_RESPONSE) { csio->scsi_status = rsp->scsi_status; - if (SCSI_STATUS_OK != rsp->scsi_status) { + if (SCSI_STATUS_OK != rsp->scsi_status) ccb_status = CAM_SCSI_STATUS_ERROR; - } + else + ccb_status = CAM_REQ_CMP; csio->resid = rsp->residual; - if (rsp->residual > 0) { - uint32_t length = rsp->response_wire_length; - /* underflow */ - if (csio->dxfer_len == (length + csio->resid)) { - ccb_status = CAM_REQ_CMP; - } - } else if (rsp->residual < 0) { + + /* + * If we've already got a SCSI error, prefer that because it + * will have more detail. + */ + if ((rsp->residual < 0) && (ccb_status == CAM_REQ_CMP)) { ccb_status = CAM_DATA_RUN_ERR; }