Author: trasz
Date: Wed Oct  4 11:35:04 2017
New Revision: 324261
URL: https://svnweb.freebsd.org/changeset/base/324261

Log:
  Fix iSCSI target panics on concurrent session teardown and display
  (eg removing a target and doing "ctladm islist -v" at the same time).
  
  Reviewed by:  manu
  Tested by:    manu
  MFC after:    2 weeks
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/cam/ctl/ctl_frontend_iscsi.c

Modified: head/sys/cam/ctl/ctl_frontend_iscsi.c
==============================================================================
--- head/sys/cam/ctl/ctl_frontend_iscsi.c       Wed Oct  4 09:54:59 2017        
(r324260)
+++ head/sys/cam/ctl/ctl_frontend_iscsi.c       Wed Oct  4 11:35:04 2017        
(r324261)
@@ -1308,18 +1308,17 @@ cfiscsi_session_delete(struct cfiscsi_session *cs)
        KASSERT(TAILQ_EMPTY(&cs->cs_waiting_for_data_out),
            ("destroying session with non-empty queue"));
 
+       mtx_lock(&softc->lock);
+       TAILQ_REMOVE(&softc->sessions, cs, cs_next);
+       mtx_unlock(&softc->lock);
+
        cfiscsi_session_unregister_initiator(cs);
        if (cs->cs_target != NULL)
                cfiscsi_target_release(cs->cs_target);
        icl_conn_close(cs->cs_conn);
        icl_conn_free(cs->cs_conn);
-
-       mtx_lock(&softc->lock);
-       TAILQ_REMOVE(&softc->sessions, cs, cs_next);
-       cv_signal(&softc->sessions_cv);
-       mtx_unlock(&softc->lock);
-
        free(cs, M_CFISCSI);
+       cv_signal(&softc->sessions_cv);
 }
 
 static int
_______________________________________________
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