git: ac4f33d2cd37 - stable/14 - mpi3mr: Cleaup setting of status in processing scsiio requests

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Fri, 19 Jan 2024 17:17:34 UTC
The branch stable/14 has been updated by mav:

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

commit ac4f33d2cd37027b7adac2b0cb4b54e1458aa4b7
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2023-11-29 01:49:30 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2024-01-19 17:16:49 +0000

    mpi3mr: Cleaup setting of status in processing scsiio requests
    
    More uniformly use mpi3mr_set_ccbstatus in mpi3mr_action_scsiio.  The
    routine mostly used it, but also has setting of status by hand. In those
    cases where we want to error out the request, use this routine.
    
    As part of this, move setting CAM_SIM_QUEUED later in the function to
    when we're sure it's been queued. Remove the places we clear it before
    this.
    
    Sponsored by:           Netflix
    Reviewed by:            mav, jhb
    Differential Revision:  https://reviews.freebsd.org/D42542
    
    (cherry picked from commit cf8c23230aabd30aa9251975dbe705da559a2d02)
---
 sys/dev/mpi3mr/mpi3mr_cam.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sys/dev/mpi3mr/mpi3mr_cam.c b/sys/dev/mpi3mr/mpi3mr_cam.c
index 44b613ad7915..b6e47eac058a 100644
--- a/sys/dev/mpi3mr/mpi3mr_cam.c
+++ b/sys/dev/mpi3mr/mpi3mr_cam.c
@@ -1025,7 +1025,7 @@ mpi3mr_action_scsiio(struct mpi3mr_cam_softc *cam_sc, union ccb *ccb)
 			cam_sc->flags |= MPI3MRSAS_QUEUE_FROZEN;
 		}
 		ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
-		ccb->ccb_h.status |= CAM_REQUEUE_REQ;
+		mpi3mr_set_ccbstatus(ccb, CAM_REQUEUE_REQ);
 		xpt_done(ccb);
 		return;
 	}
@@ -1099,39 +1099,38 @@ mpi3mr_action_scsiio(struct mpi3mr_cam_softc *cam_sc, union ccb *ccb)
 	mpi3mr_dprint(sc, MPI3MR_TRACE, "[QID:%d]: func: %s line:%d CDB: 0x%x targetid: %x SMID: 0x%x\n",
 		(queue_idx + 1), __func__, __LINE__, scsi_opcode, csio->ccb_h.target_id, cm->hosttag);
 
-	ccb->ccb_h.status |= CAM_SIM_QUEUED;
-
 	switch ((ccb->ccb_h.flags & CAM_DATA_MASK)) {
 	case CAM_DATA_PADDR:
 	case CAM_DATA_SG_PADDR:
 		device_printf(sc->mpi3mr_dev, "%s: physical addresses not supported\n",
 		    __func__);
 		mpi3mr_release_command(cm);
-		ccb->ccb_h.status = CAM_REQ_INVALID;
-		ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
+		mpi3mr_set_ccbstatus(ccb, CAM_REQ_INVALID);
 		xpt_done(ccb);
 		return;
 	case CAM_DATA_SG:
 		device_printf(sc->mpi3mr_dev, "%s: scatter gather is not supported\n",
 		    __func__);
 		mpi3mr_release_command(cm);
-		ccb->ccb_h.status = CAM_REQ_INVALID;
+		mpi3mr_set_ccbstatus(ccb, CAM_REQ_INVALID);
 		xpt_done(ccb);
 		return;
 	case CAM_DATA_VADDR:
 	case CAM_DATA_BIO:
 		if (csio->dxfer_len > (MPI3MR_SG_DEPTH * MPI3MR_4K_PGSZ)) {
+			mpi3mr_set_ccbstatus(ccb, CAM_REQ_TOO_BIG);
 			mpi3mr_release_command(cm);
-			ccb->ccb_h.status = CAM_REQ_TOO_BIG;
 			xpt_done(ccb);
 			return;
 		}
+		ccb->ccb_h.status |= CAM_SIM_QUEUED;
 		cm->length = csio->dxfer_len;
 		if (cm->length)
 			cm->data = csio->data_ptr;
 		break;
 	default:
-		ccb->ccb_h.status = CAM_REQ_INVALID;
+		mpi3mr_release_command(cm);
+		mpi3mr_set_ccbstatus(ccb, CAM_REQ_INVALID);
 		xpt_done(ccb);
 		return;
 	}