Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Sep 2021 07:48:16 GMT
From:      Ram Kishore Vegesna <ram@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 1af49c2eeb4a - main - ocs_fc: Fix CAM status reporting in ocs_fc(4) when no data is returned.
Message-ID:  <202109300748.18U7mG0e046481@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by ram:

URL: https://cgit.FreeBSD.org/src/commit/?id=1af49c2eeb4a05f524ed9a6657c741bc96fbaf87

commit 1af49c2eeb4a05f524ed9a6657c741bc96fbaf87
Author:     Ram Kishore Vegesna <ram@FreeBSD.org>
AuthorDate: 2021-09-24 09:19:49 +0000
Commit:     Ram Kishore Vegesna <ram@FreeBSD.org>
CommitDate: 2021-09-30 07:31:16 +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
---
 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;
 		}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109300748.18U7mG0e046481>