Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Mar 2017 20:20:00 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r315025 - head/sys/cam/ctl
Message-ID:  <201703102020.v2AKK09t024998@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Fri Mar 10 20:20:00 2017
New Revision: 315025
URL: https://svnweb.freebsd.org/changeset/base/315025

Log:
  Switch work_queue from TAILQ to STAILQ.
  
  It is mostly FIFO and we don't need random removal there.
  
  MFC after:	2 weeks

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

Modified: head/sys/cam/ctl/scsi_ctl.c
==============================================================================
--- head/sys/cam/ctl/scsi_ctl.c	Fri Mar 10 20:07:38 2017	(r315024)
+++ head/sys/cam/ctl/scsi_ctl.c	Fri Mar 10 20:20:00 2017	(r315025)
@@ -105,7 +105,7 @@ struct ctlfe_lun_softc {
 	int	 atios_alloced;		/* Number of ATIOs not freed */
 	int	 inots_alloced;		/* Number of INOTs not freed */
 	struct task	refdrain_task;
-	TAILQ_HEAD(, ccb_hdr) work_queue;
+	STAILQ_HEAD(, ccb_hdr) work_queue;
 	STAILQ_ENTRY(ctlfe_lun_softc) links;
 };
 
@@ -460,7 +460,7 @@ ctlferegister(struct cam_periph *periph,
 	softc = (struct ctlfe_lun_softc *)arg;
 	bus_softc = softc->parent_softc;
 	
-	TAILQ_INIT(&softc->work_queue);
+	STAILQ_INIT(&softc->work_queue);
 	softc->periph = periph;
 	periph->softc = softc;
 
@@ -749,14 +749,13 @@ ctlfestart(struct cam_periph *periph, un
 	softc = (struct ctlfe_lun_softc *)periph->softc;
 
 next:
-	ccb_h = TAILQ_FIRST(&softc->work_queue);
+	/* Take the ATIO off the work queue */
+	ccb_h = STAILQ_FIRST(&softc->work_queue);
 	if (ccb_h == NULL) {
 		xpt_release_ccb(start_ccb);
 		return;
 	}
-
-	/* Take the ATIO off the work queue */
-	TAILQ_REMOVE(&softc->work_queue, ccb_h, periph_links.tqe);
+	STAILQ_REMOVE_HEAD(&softc->work_queue, periph_links.stqe);
 	atio = (struct ccb_accept_tio *)ccb_h;
 	io = (union ctl_io *)ccb_h->io_ptr;
 	csio = &start_ccb->csio;
@@ -881,7 +880,7 @@ next:
 	/*
 	 * If we still have work to do, ask for another CCB.
 	 */
-	if (!TAILQ_EMPTY(&softc->work_queue))
+	if (!STAILQ_EMPTY(&softc->work_queue))
 		xpt_schedule(periph, CAM_PRIORITY_NORMAL);
 }
 
@@ -1207,8 +1206,8 @@ ctlfedone(struct cam_periph *periph, uni
 			io->scsiio.io_hdr.status = CTL_STATUS_NONE;
 			io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED;
 			xpt_release_ccb(done_ccb);
-			TAILQ_INSERT_HEAD(&softc->work_queue, &atio->ccb_h,
-					  periph_links.tqe);
+			STAILQ_INSERT_HEAD(&softc->work_queue, &atio->ccb_h,
+					  periph_links.stqe);
 			xpt_schedule(periph, CAM_PRIORITY_NORMAL);
 			break;
 		}
@@ -1823,7 +1822,7 @@ ctlfe_dump_queue(struct ctlfe_lun_softc 
 	periph = softc->periph;
 	num_items = 0;
 
-	TAILQ_FOREACH(hdr, &softc->work_queue, periph_links.tqe) {
+	STAILQ_FOREACH(hdr, &softc->work_queue, periph_links.stqe) {
 		union ctl_io *io = hdr->io_ptr;
 
 		num_items++;
@@ -1878,8 +1877,8 @@ ctlfe_datamove(union ctl_io *io)
 	io->io_hdr.flags |= CTL_FLAG_DMA_QUEUED;
 	if ((io->io_hdr.status & CTL_STATUS_MASK) != CTL_STATUS_NONE)
 		io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED;
-	TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h,
-			  periph_links.tqe);
+	STAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h,
+			  periph_links.stqe);
 	xpt_schedule(periph, CAM_PRIORITY_NORMAL);
 	cam_periph_unlock(periph);
 }
@@ -1931,8 +1930,8 @@ ctlfe_done(union ctl_io *io)
 		return;
 	} else {
 		io->io_hdr.flags |= CTL_FLAG_STATUS_QUEUED;
-		TAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h,
-				  periph_links.tqe);
+		STAILQ_INSERT_TAIL(&softc->work_queue, &ccb->ccb_h,
+				  periph_links.stqe);
 		xpt_schedule(periph, CAM_PRIORITY_NORMAL);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703102020.v2AKK09t024998>