Author: mav
Date: Wed Mar 27 18:55:01 2013
New Revision: 248800
URL: http://svnweb.freebsd.org/changeset/base/248800

Log:
  On SIM destruction free associated CCBs, preallocated inside xpt_get_ccb().
  Before this change they were just leaked.  Fortunately USB sticks now use
  only one CCB, and so leak was only 2KB per detach, while other bigger SIMs
  with much more allocated CCBs are rarely detached.
  
  MFC after:    2 weeks

Modified:
  head/sys/cam/cam_sim.c

Modified: head/sys/cam/cam_sim.c
==============================================================================
--- head/sys/cam/cam_sim.c      Wed Mar 27 18:06:28 2013        (r248799)
+++ head/sys/cam/cam_sim.c      Wed Mar 27 18:55:01 2013        (r248800)
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
 #include <cam/cam_ccb.h>
 #include <cam/cam_sim.h>
 #include <cam/cam_queue.h>
+#include <cam/cam_xpt.h>
 
 #define CAM_PATH_ANY (u_int32_t)-1
 
@@ -105,6 +106,7 @@ cam_sim_alloc(sim_action_func sim_action
 void
 cam_sim_free(struct cam_sim *sim, int free_devq)
 {
+       union ccb *ccb;
        int error;
 
        sim->refcount--;
@@ -115,6 +117,10 @@ cam_sim_free(struct cam_sim *sim, int fr
 
        KASSERT(sim->refcount == 0, ("sim->refcount == 0"));
 
+       while ((ccb = (union ccb *)SLIST_FIRST(&sim->ccb_freeq)) != NULL) {
+               SLIST_REMOVE_HEAD(&sim->ccb_freeq, xpt_links.sle);
+               xpt_free_ccb(ccb);
+       }
        if (free_devq)
                cam_simq_free(sim->devq);
        free(sim, M_CAMSIM);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to