patch-1.3.79 linux/drivers/block/ll_rw_blk.c

Next file: linux/drivers/cdrom/cdu31a.c
Previous file: linux/drivers/block/ide.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.78/linux/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c
@@ -85,8 +85,9 @@
 
 	save_flags(flags);
 	cli();
-	if (dev->current_request)
-		(dev->request_fn)();
+	dev->current_request = dev->plug.next;
+	dev->plug.next = NULL;
+	(dev->request_fn)();
 	restore_flags(flags);
 }
 
@@ -94,11 +95,20 @@
  * "plug" the device if there are no outstanding requests: this will
  * force the transfer to start only after we have put all the requests
  * on the list.
+ *
+ * Note! We can do the check without interrupts off, because interrupts
+ * will never add a new request to the queue, only take requests off.. 
  */
 static inline void plug_device(struct blk_dev_struct * dev)
 {
-	if (!dev->current_request && !IS_PLUGGED(dev)) {
+	if (!dev->current_request) {
+		unsigned long flags;
+
+		save_flags(flags);
+		cli();
+		dev->current_request = &dev->plug;
 		queue_task_irq_off(&dev->plug_tq, &tq_scheduler);
+		restore_flags(flags);
 	}
 }
 
@@ -250,8 +260,7 @@
 	if (!(tmp = dev->current_request)) {
 		dev->current_request = req;
 		up (&request_lock);
-		if (!IS_PLUGGED(dev))
-			(dev->request_fn)();
+		(dev->request_fn)();
 		sti();
 		return;
 	}
@@ -266,7 +275,7 @@
 
 	up (&request_lock);
 /* for SCSI devices, call request_fn unconditionally */
-	if (!IS_PLUGGED(dev) && scsi_major(MAJOR(req->rq_dev)) && MAJOR(req->rq_dev)!=MD_MAJOR)
+	if (scsi_major(MAJOR(req->rq_dev)) && MAJOR(req->rq_dev)!=MD_MAJOR)
 		(dev->request_fn)();
 
 	sti();
@@ -609,6 +618,9 @@
 	for (dev = blk_dev + MAX_BLKDEV; dev-- != blk_dev;) {
 		dev->request_fn      = NULL;
 		dev->current_request = NULL;
+		dev->plug.rq_status  = RQ_INACTIVE;
+		dev->plug.cmd        = -1;
+		dev->plug.next       = NULL;
 		dev->plug_tq.routine = &unplug_device;
 		dev->plug_tq.data    = dev;
 	}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this