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

Next file: linux/drivers/block/rd.c
Previous file: linux/drivers/block/cpqarray.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.23/linux/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c
@@ -286,15 +286,39 @@
 	else ro_bits[major][minor >> 5] &= ~(1 << (minor & 31));
 }
 
-static inline void drive_stat_acct(int cmd, unsigned long nr_sectors,
-                                   short disk_index)
+static inline void drive_stat_acct(struct request *req,
+                                   unsigned long nr_sectors, int new_io)
 {
-	kstat.dk_drive[disk_index]++;
-	if (cmd == READ) {
-		kstat.dk_drive_rio[disk_index]++;
+	int major = MAJOR(req->rq_dev);
+	int minor = MINOR(req->rq_dev);
+	unsigned int disk_index;
+
+	switch (major) {
+		case DAC960_MAJOR+0:
+			disk_index = (minor & 0x00f8) >> 3;
+			break;
+		case SCSI_DISK0_MAJOR:
+			disk_index = (minor & 0x00f0) >> 4;
+			break;
+		case IDE0_MAJOR:	/* same as HD_MAJOR */
+		case XT_DISK_MAJOR:
+			disk_index = (minor & 0x0040) >> 6;
+			break;
+		case IDE1_MAJOR:
+			disk_index = ((minor & 0x0040) >> 6) + 2;
+			break;
+		default:
+			return;
+	}
+	if (disk_index >= DK_NDRIVE)
+		return;
+
+	kstat.dk_drive[disk_index] += new_io;
+	if (req->cmd == READ) {
+		kstat.dk_drive_rio[disk_index] += new_io;
 		kstat.dk_drive_rblk[disk_index] += nr_sectors;
-	} else if (cmd == WRITE) {
-		kstat.dk_drive_wio[disk_index]++;
+	} else if (req->cmd == WRITE) {
+		kstat.dk_drive_wio[disk_index] += new_io;
 		kstat.dk_drive_wblk[disk_index] += nr_sectors;
 	} else
 		printk(KERN_ERR "drive_stat_acct: cmd not R/W?\n");
@@ -313,35 +337,11 @@
 void add_request(struct blk_dev_struct * dev, struct request * req)
 {
 	int major = MAJOR(req->rq_dev);
-	int minor = MINOR(req->rq_dev);
 	struct request * tmp, **current_request;
-	short		 disk_index;
 	unsigned long flags;
 	int queue_new_request = 0;
 
-	switch (major) {
-		case DAC960_MAJOR+0:
-			disk_index = (minor & 0x00f8) >> 3;
-			if (disk_index < 4)
-				drive_stat_acct(req->cmd, req->nr_sectors, disk_index);
-			break;
-		case SCSI_DISK0_MAJOR:
-			disk_index = (minor & 0x00f0) >> 4;
-			if (disk_index < 4)
-				drive_stat_acct(req->cmd, req->nr_sectors, disk_index);
-			break;
-		case IDE0_MAJOR:	/* same as HD_MAJOR */
-		case XT_DISK_MAJOR:
-			disk_index = (minor & 0x0040) >> 6;
-			drive_stat_acct(req->cmd, req->nr_sectors, disk_index);
-			break;
-		case IDE1_MAJOR:
-			disk_index = ((minor & 0x0040) >> 6) + 2;
-			drive_stat_acct(req->cmd, req->nr_sectors, disk_index);
-		default:
-			break;
-	}
-
+	drive_stat_acct(req, req->nr_sectors, 1);
 	req->next = NULL;
 
 	/*
@@ -575,6 +575,7 @@
 				req->bhtail->b_reqnext = bh;
 				req->bhtail = bh;
 			    	req->nr_sectors += count;
+				drive_stat_acct(req, count, 0);
 				/* Can we now merge this req with the next? */
 				attempt_merge(req, max_sectors);
 			/* or to the beginning? */
@@ -585,6 +586,7 @@
 			    	req->current_nr_sectors = count;
 			    	req->sector = sector;
 			    	req->nr_sectors += count;
+				drive_stat_acct(req, count, 0);
 			} else
 				continue;
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)