Author: trasz
Date: Tue Mar 26 15:47:13 2019
New Revision: 345549
URL: https://svnweb.freebsd.org/changeset/base/345549

Log:
  Make smartpqi(4) behave better when running out of memory, by returning
  CAM_RESRC_UNAVAIL instead of CAM_REQUEUE_REQ.  This makes CAM delay a bit
  before retrying, so that the retries actually get a chance to succeed.
  
  Reviewed by:  sbruno
  MFC after:    2 weeks
  Sponsored by: Klara Inc.
  Differential Revision:        https://reviews.freebsd.org/D19696

Modified:
  head/sys/dev/smartpqi/smartpqi_cam.c

Modified: head/sys/dev/smartpqi/smartpqi_cam.c
==============================================================================
--- head/sys/dev/smartpqi/smartpqi_cam.c        Tue Mar 26 15:44:06 2019        
(r345548)
+++ head/sys/dev/smartpqi/smartpqi_cam.c        Tue Mar 26 15:47:13 2019        
(r345549)
@@ -458,6 +458,15 @@ void os_aio_response_error(rcb_t *rcb, aio_path_error_
        DBG_IO("OUT\n");
 }
 
+static void
+pqi_freeze_ccb(union ccb *ccb)
+{
+       if ((ccb->ccb_h.status & CAM_DEV_QFRZN) == 0) {
+               ccb->ccb_h.status |= CAM_DEV_QFRZN;
+               xpt_freeze_devq(ccb->ccb_h.path, 1);
+       }
+}
+
 /*
  * Command-mapping helper function - populate this command's s/g table.
  */
@@ -472,9 +481,8 @@ pqi_request_map_helper(void *arg, bus_dma_segment_t *s
 
        if(  error || nseg > softs->pqi_cap.max_sg_elem )
        {
-               xpt_freeze_simq(softs->os_specific.sim, 1);
-               rcb->cm_ccb->ccb_h.status |= (CAM_REQUEUE_REQ|
-                                               CAM_RELEASE_SIMQ);
+               rcb->cm_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+               pqi_freeze_ccb(rcb->cm_ccb);
                DBG_ERR_BTL(rcb->dvp, "map failed err = %d or nseg(%d) > 
sgelem(%d)\n", 
                        error, nseg, softs->pqi_cap.max_sg_elem);
                pqi_unmap_request(rcb);
@@ -484,9 +492,8 @@ pqi_request_map_helper(void *arg, bus_dma_segment_t *s
 
        rcb->sgt = os_mem_alloc(softs, nseg * sizeof(rcb_t));
        if (rcb->sgt == NULL) {
-               xpt_freeze_simq(softs->os_specific.sim, 1);
-               rcb->cm_ccb->ccb_h.status |= (CAM_REQUEUE_REQ|
-                                               CAM_RELEASE_SIMQ);
+               rcb->cm_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+               pqi_freeze_ccb(rcb->cm_ccb);
                DBG_ERR_BTL(rcb->dvp, "os_mem_alloc() failed; nseg = %d\n", 
nseg);
                pqi_unmap_request(rcb);
                xpt_done((union ccb *)rcb->cm_ccb);
@@ -514,9 +521,8 @@ pqi_request_map_helper(void *arg, bus_dma_segment_t *s
 
        if (error) {
                rcb->req_pending = false;
-               xpt_freeze_simq(softs->os_specific.sim, 1);
-               rcb->cm_ccb->ccb_h.status |= (CAM_REQUEUE_REQ
-                                               |CAM_RELEASE_SIMQ);
+               rcb->cm_ccb->ccb_h.status = CAM_RESRC_UNAVAIL;
+               pqi_freeze_ccb(rcb->cm_ccb);
                DBG_ERR_BTL(rcb->dvp, "Build IO failed, error = %d\n", error);
                pqi_unmap_request(rcb);
                xpt_done((union ccb *)rcb->cm_ccb);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to