lkml.org 
[lkml]   [2000]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Fix disk statistic reporting to include all disks
This patch fixes the enhanced disk statistics to report all drives
so IDE1 - IDE3 (/dev/hdc - /dev/hdh) can be monitored.

It is also more efficient when scanning the kstat disk tables
during a read of /proc/stat because entries in the table are looked
at only if a disk has registered any activity.


Bill


Bill Wilson <bill@gkrellm.net>



diff -ur linux-2.4.0-test7/drivers/block/ll_rw_blk.c
linux/drivers/block/ll_rw_blk.c
--- linux-2.4.0-test7/drivers/block/ll_rw_blk.c Sat Aug 26 12:28:23 2000
+++ linux/drivers/block/ll_rw_blk.c Tue Aug 29 07:58:18 2000
@@ -551,19 +551,26 @@
unsigned long nr_sectors, int new_io)
{
unsigned int major = MAJOR(dev);
- unsigned int index;
+ unsigned int disk;
+ int index;

- index = disk_index(dev);
- if ((index >= DK_MAX_DISK) || (major >= DK_MAX_MAJOR))
+ disk = disk_index(dev);
+ if ((disk >= DK_MAX_DISK) || (major >= MAX_BLKDEV))
return;
-
- kstat.dk_drive[major][index] += new_io;
+ if ((index = kstat.dk_drive_map[major] - 1) < 0) {
+ if (kstat.dk_drive_max >= DK_MAX_MAJOR)
+ return;
+ index = kstat.dk_drive_max++;
+ kstat.dk_drive_map[major] = index + 1;
+ kstat.dk_drive_major[index] = (int) major;
+ }
+ kstat.dk_drive[index][disk] += new_io;
if (rw == READ) {
- kstat.dk_drive_rio[major][index] += new_io;
- kstat.dk_drive_rblk[major][index] += nr_sectors;
+ kstat.dk_drive_rio[index][disk] += new_io;
+ kstat.dk_drive_rblk[index][disk] += nr_sectors;
} else if (rw == WRITE) {
- kstat.dk_drive_wio[major][index] += new_io;
- kstat.dk_drive_wblk[major][index] += nr_sectors;
+ kstat.dk_drive_wio[index][disk] += new_io;
+ kstat.dk_drive_wblk[index][disk] += nr_sectors;
} else
printk(KERN_ERR "drive_stat_acct: cmd not R/W?\n");
}
diff -ur linux-2.4.0-test7/drivers/block/md.c linux/drivers/block/md.c
--- linux-2.4.0-test7/drivers/block/md.c Sat Aug 26 12:28:23 2000
+++ linux/drivers/block/md.c Tue Aug 29 07:58:18 2000
@@ -3218,6 +3218,7 @@
struct md_list_head *tmp;
int idle;
unsigned long curr_events;
+ int index;

idle = 1;
ITERATE_RDEV(mddev,rdev,tmp) {
@@ -3226,9 +3227,11 @@

if ((idx >= DK_MAX_DISK) || (major >= DK_MAX_MAJOR))
continue;
-
- curr_events = kstat.dk_drive_rblk[major][idx] +
- kstat.dk_drive_wblk[major][idx]
;
+ if ((index = kstat.dk_drive_map[major] - 1) < 0)
+ curr_events = 0;
+ else
+ curr_events = kstat.dk_drive_rblk[index][idx] +
+ kstat.dk_drive_wblk[index][idx]
;
curr_events -= sync_io[major][idx];
// printk("events(major: %d, idx: %d): %ld\n", major, idx,
curr_events);
if (curr_events != rdev->last_events) {
diff -ur linux-2.4.0-test7/fs/proc/proc_misc.c linux/fs/proc/proc_misc.c
--- linux-2.4.0-test7/fs/proc/proc_misc.c Mon Aug 7 13:20:10 2000
+++ linux/fs/proc/proc_misc.c Tue Aug 29 07:58:18 2000
@@ -288,7 +288,7 @@
extern unsigned long total_forks;
unsigned long jif = jiffies;
unsigned int sum = 0, user = 0, nice = 0, system = 0;
- int major, disk;
+ int index, major, disk;

for (i = 0 ; i < smp_num_cpus; i++) {
int cpu = cpu_logical_map(i), j;
@@ -326,20 +326,22 @@

len += sprintf(page + len, "\ndisk_io: ");

- for (major = 0; major < DK_MAX_MAJOR; major++) {
+ for (index = 0; index < kstat.dk_drive_max; index++) {
+ if ((major = kstat.dk_drive_major[index]) == 0)
+ continue;
for (disk = 0; disk < DK_MAX_DISK; disk++) {
- int active = kstat.dk_drive_rio[major][disk] +
- kstat.dk_drive_rblk[major][disk] +
- kstat.dk_drive_wio[major][disk] +
- kstat.dk_drive_wblk[major][disk];
+ int active = kstat.dk_drive_rio[index][disk] +
+ kstat.dk_drive_rblk[index][disk] +
+ kstat.dk_drive_wio[index][disk] +
+ kstat.dk_drive_wblk[index][disk];
if (active)
len += sprintf(page + len,
"(%u,%u):(%u,%u,%u,%u) ",
major, disk,
- kstat.dk_drive_rio[major][disk],
- kstat.dk_drive_rblk[major][disk],
- kstat.dk_drive_wio[major][disk],
- kstat.dk_drive_wblk[major][disk]
+ kstat.dk_drive_rio[index][disk],
+ kstat.dk_drive_rblk[index][disk],
+ kstat.dk_drive_wio[index][disk],
+ kstat.dk_drive_wblk[index][disk]
);
}
}
diff -ur linux-2.4.0-test7/include/linux/genhd.h linux/include/linux/genhd.h
--- linux-2.4.0-test7/include/linux/genhd.h Mon Aug 7 13:20:12 2000
+++ linux/include/linux/genhd.h Tue Aug 29 07:58:18 2000
@@ -249,12 +249,19 @@
case SCSI_DISK0_MAJOR:
index = (minor & 0x00f0) >> 4;
break;
+ case SCSI_CDROM_MAJOR:
+ case SCSI_GENERIC_MAJOR:
+ case FLOPPY_MAJOR:
+ index = (minor & 0x000f);
+ break;
case IDE0_MAJOR: /* same as HD_MAJOR */
+ case IDE1_MAJOR:
+ case IDE2_MAJOR:
+ case IDE3_MAJOR:
+ case IDE4_MAJOR:
+ case IDE5_MAJOR:
case XT_DISK_MAJOR:
index = (minor & 0x0040) >> 6;
- break;
- case IDE1_MAJOR:
- index = ((minor & 0x0040) >> 6) + 2;
break;
default:
return 0;
diff -ur linux-2.4.0-test7/include/linux/kernel_stat.h
linux/include/linux/kernel_stat.h
--- linux-2.4.0-test7/include/linux/kernel_stat.h Mon Aug 7 13:20:12 2000
+++ linux/include/linux/kernel_stat.h Tue Aug 29 07:58:18 2000
@@ -19,6 +19,9 @@
unsigned int per_cpu_user[NR_CPUS],
per_cpu_nice[NR_CPUS],
per_cpu_system[NR_CPUS];
+ int dk_drive_max;
+ int dk_drive_map[MAX_BLKDEV];
+ int dk_drive_major[DK_MAX_MAJOR];
unsigned int dk_drive[DK_MAX_MAJOR][DK_MAX_DISK];
unsigned int dk_drive_rio[DK_MAX_MAJOR][DK_MAX_DISK];
unsigned int dk_drive_wio[DK_MAX_MAJOR][DK_MAX_DISK];
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.092 / U:0.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site