FreeBSD/sys/cam/scsi/scsi_target.c
/* Cancel all pending requests and CCBs awaiting work. */
Cancel all pending requests and CCBs awaiting work.
Cancel all pending requests and CCBs awaiting work .
static void
abort_all_pending(struct targ_softc *softc)
{
	struct targ_cmd_descr   *descr;
	struct ccb_abort	 cab;
	struct ccb_hdr		*ccb_h;
	CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH, ("abort_all_pending\n"));
	while ((descr = TAILQ_FIRST(&softc->work_queue)) != NULL) {
		CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
			  ("Aborting descr from workq %p\n", descr));
		TAILQ_REMOVE(&softc->work_queue, descr, tqe);
		TAILQ_INSERT_TAIL(&softc->abort_queue, descr, tqe);
	}
	xpt_setup_ccb(&cab.ccb_h, softc->path, CAM_PRIORITY_NORMAL);
	cab.ccb_h.func_code = XPT_ABORT;
	cab.ccb_h.status = CAM_REQ_CMP_ERR;
	TAILQ_FOREACH(ccb_h, &softc->pending_ccb_queue, periph_links.tqe) {
		CAM_DEBUG(softc->path, CAM_DEBUG_PERIPH,
			  ("Aborting pending CCB %p\n", ccb_h));
		cab.abort_ccb = (union ccb *)ccb_h;
		xpt_action((union ccb *)&cab);
		if (cab.ccb_h.status != CAM_REQ_CMP) {
			xpt_print(cab.ccb_h.path,
			    "Unable to abort CCB, status %#x\n",
			    cab.ccb_h.status);
		}
	}
	if (cab.ccb_h.status == CAM_REQ_CMP) {
		cam_periph_sleep(softc->periph, &softc->pending_ccb_queue,
		       PRIBIO | PCATCH, "tgabrt", 0);
	}
	if (!TAILQ_EMPTY(&softc->user_ccb_queue)
	 || !TAILQ_EMPTY(&softc->abort_queue)) {
		cam_periph_unlock(softc->periph);
		notify_user(softc);
		cam_periph_lock(softc->periph);
	}
}
static void abort_all_pending ( struct targ_softc * softc ) { struct targ_cmd_descr * descr ; struct ccb_abort cab ; struct ccb_hdr * ccb_h ; CAM_DEBUG ( softc -> path , CAM_DEBUG_PERIPH , ( " \n " ) ) ; while ( ( descr = TAILQ_FIRST ( & softc -> work_queue ) ) != NULL ) { CAM_DEBUG ( softc -> path , CAM_DEBUG_PERIPH , ( " \n " , descr ) ) ; TAILQ_REMOVE ( & softc -> work_queue , descr , tqe ) ; TAILQ_INSERT_TAIL ( & softc -> abort_queue , descr , tqe ) ; } xpt_setup_ccb ( & cab . ccb_h , softc -> path , CAM_PRIORITY_NORMAL ) ; cab . ccb_h . func_code = XPT_ABORT ; cab . ccb_h . status = CAM_REQ_CMP_ERR ; TAILQ_FOREACH ( ccb_h , & softc -> pending_ccb_queue , periph_links . tqe ) { CAM_DEBUG ( softc -> path , CAM_DEBUG_PERIPH , ( " \n " , ccb_h ) ) ; cab . abort_ccb = ( union ccb * ) ccb_h ; xpt_action ( ( union ccb * ) & cab ) ; if ( cab . ccb_h . status != CAM_REQ_CMP ) { xpt_print ( cab . ccb_h . path , " \n " , cab . ccb_h . status ) ; } } if ( cab . ccb_h . status == CAM_REQ_CMP ) { cam_periph_sleep ( softc -> periph , & softc -> pending_ccb_queue , PRIBIO | PCATCH , " " , 0 ) ; } if ( ! TAILQ_EMPTY ( & softc -> user_ccb_queue ) || ! TAILQ_EMPTY ( & softc -> abort_queue ) ) { cam_periph_unlock ( softc -> periph ) ; notify_user ( softc ) ; cam_periph_lock ( softc -> periph ) ; } }
Cancel all pending requests and CCBs awaiting work.
Cancel all pending requests and CCBs awaiting work .
/* First abort the descriptors awaiting resources */ /* 
	 * Then abort all pending CCBs.
	 * targdone() will return the aborted CCB via user_ccb_queue
	 */ /* If we aborted at least one pending CCB ok, wait for it. */ /* If we aborted anything from the work queue, wakeup user. */