Author: mav
Date: Thu Jun 14 14:58:51 2018
New Revision: 335142
URL: https://svnweb.freebsd.org/changeset/base/335142

Log:
  MFC r328089 (by imp):
  Move setting of CAM_SIM_QUEUED to before we actually submit it to the
  hardware. Setting it after is racy, and we can lose the race on a
  heavily loaded system.

Modified:
  stable/11/sys/dev/nvme/nvme_sim.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme_sim.c
==============================================================================
--- stable/11/sys/dev/nvme/nvme_sim.c   Thu Jun 14 14:53:24 2018        
(r335141)
+++ stable/11/sys/dev/nvme/nvme_sim.c   Thu Jun 14 14:58:51 2018        
(r335142)
@@ -76,6 +76,7 @@ nvme_sim_nvmeio_done(void *ccb_arg, const struct nvme_
         * it means. Make our best guess, though for the status code.
         */
        memcpy(&ccb->nvmeio.cpl, cpl, sizeof(*cpl));
+       ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
        if (nvme_completion_is_error(cpl)) {
                ccb->ccb_h.status = CAM_REQ_CMP_ERR;
                xpt_done(ccb);
@@ -114,6 +115,7 @@ nvme_sim_nvmeio(struct cam_sim *sim, union ccb *ccb)
                xpt_done(ccb);
                return;
        }
+       ccb->ccb_h.status |= CAM_SIM_QUEUED;
 
        memcpy(&req->cmd, &ccb->nvmeio.cmd, sizeof(ccb->nvmeio.cmd));
 
@@ -121,8 +123,6 @@ nvme_sim_nvmeio(struct cam_sim *sim, union ccb *ccb)
                nvme_ctrlr_submit_io_request(ctrlr, req);
        else
                nvme_ctrlr_submit_admin_request(ctrlr, req);
-
-       ccb->ccb_h.status |= CAM_SIM_QUEUED;
 }
 
 static void
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to