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

Next file: linux/drivers/block/xd.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.3/linux/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c
@@ -520,9 +520,9 @@
 
 void ll_rw_swap_file(int rw, int dev, unsigned int *b, int nb, char *buf)
 {
-	int i;
+	int i, j;
 	int buffersize;
-	struct request * req;
+	struct request * req[8];
 	unsigned int major = MAJOR(dev);
 	struct semaphore sem = MUTEX_LOCKED;
 
@@ -542,20 +542,34 @@
 	
 	buffersize = PAGE_SIZE / nb;
 
-	for (i=0; i<nb; i++, buf += buffersize)
+	for (j=0, i=0; i<nb;)
 	{
-		req = get_request_wait(NR_REQUEST, dev);
-		req->cmd = rw;
-		req->errors = 0;
-		req->sector = (b[i] * buffersize) >> 9;
-		req->nr_sectors = buffersize >> 9;
-		req->current_nr_sectors = buffersize >> 9;
-		req->buffer = buf;
-		req->sem = &sem;
-		req->bh = NULL;
-		req->next = NULL;
-		add_request(major+blk_dev,req);
-		down(&sem);
+		for (; j < 8 && i < nb; j++, i++, buf += buffersize)
+		{
+			if (j == 0) {
+				req[j] = get_request_wait(NR_REQUEST, dev);
+			} else {
+				cli();
+				req[j] = get_request(NR_REQUEST, dev);
+				sti();
+				if (req[j] == NULL)
+					break;
+			}
+			req[j]->cmd = rw;
+			req[j]->errors = 0;
+			req[j]->sector = (b[i] * buffersize) >> 9;
+			req[j]->nr_sectors = buffersize >> 9;
+			req[j]->current_nr_sectors = buffersize >> 9;
+			req[j]->buffer = buf;
+			req[j]->sem = &sem;
+			req[j]->bh = NULL;
+			req[j]->next = NULL;
+			add_request(major+blk_dev,req[j]);
+		}
+		while (j > 0) {
+			j--;
+			down(&sem);
+		}
 	}
 }
 

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