]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | diff -ur g/linux-2.4.26/drivers/block/ll_rw_blk.c h/linux-2.4.26/drivers/block/ll_rw_blk.c |
2 | --- g/linux-2.4.26/drivers/block/ll_rw_blk.c 2004-04-14 14:05:29.000000000 +0100 | |
3 | +++ h/linux-2.4.26/drivers/block/ll_rw_blk.c 2004-06-07 19:36:15.000000000 +0100 | |
4 | @@ -696,20 +696,26 @@ | |
5 | { | |
6 | unsigned int major = MAJOR(dev); | |
7 | unsigned int index; | |
8 | + dk_stat_t * ds; | |
9 | ||
10 | + ds = kstat.dk_drive_info[major]; | |
11 | + if (ds == NULL) | |
12 | + return; | |
13 | + | |
14 | index = disk_index(dev); | |
15 | - if ((index >= DK_MAX_DISK) || (major >= DK_MAX_MAJOR)) | |
16 | + if (index >= DK_MAX_DISK) | |
17 | return; | |
18 | - | |
19 | - kstat.dk_drive[major][index] += new_io; | |
20 | + | |
21 | + ds += index; | |
22 | if (rw == READ) { | |
23 | - kstat.dk_drive_rio[major][index] += new_io; | |
24 | - kstat.dk_drive_rblk[major][index] += nr_sectors; | |
25 | + ds->dk_drive_rio += new_io; | |
26 | + ds->dk_drive_rblk += nr_sectors; | |
27 | } else if (rw == WRITE) { | |
28 | - kstat.dk_drive_wio[major][index] += new_io; | |
29 | - kstat.dk_drive_wblk[major][index] += nr_sectors; | |
30 | - } else | |
31 | + ds->dk_drive_wio += new_io; | |
32 | + ds->dk_drive_wblk += nr_sectors; | |
33 | + } else { | |
34 | printk(KERN_ERR "drive_stat_acct: cmd not R/W?\n"); | |
35 | + } | |
36 | } | |
37 | ||
38 | #ifdef CONFIG_BLK_STATS | |
39 | diff -ur g/linux-2.4.26/drivers/md/md.c h/linux-2.4.26/drivers/md/md.c | |
40 | --- g/linux-2.4.26/drivers/md/md.c 2003-08-25 12:44:42.000000000 +0100 | |
41 | +++ h/linux-2.4.26/drivers/md/md.c 2004-06-07 19:36:15.000000000 +0100 | |
42 | @@ -3381,12 +3381,15 @@ | |
43 | ITERATE_RDEV(mddev,rdev,tmp) { | |
44 | int major = MAJOR(rdev->dev); | |
45 | int idx = disk_index(rdev->dev); | |
46 | + dk_stat_t * ds; | |
47 | ||
48 | if ((idx >= DK_MAX_DISK) || (major >= DK_MAX_MAJOR)) | |
49 | continue; | |
50 | ||
51 | - curr_events = kstat.dk_drive_rblk[major][idx] + | |
52 | - kstat.dk_drive_wblk[major][idx] ; | |
53 | + if ((ds = kstat.dk_drive_info[major]) == NULL) | |
54 | + continue; | |
55 | + ds += idx; | |
56 | + curr_events = ds->dk_drive_rblk + ds->dk_drive_wblk; | |
57 | curr_events -= sync_io[major][idx]; | |
58 | if ((curr_events - rdev->last_events) > 32) { | |
59 | rdev->last_events = curr_events; | |
60 | diff -ur g/linux-2.4.26/fs/block_dev.c h/linux-2.4.26/fs/block_dev.c | |
61 | --- g/linux-2.4.26/fs/block_dev.c 2003-06-13 15:51:37.000000000 +0100 | |
62 | +++ h/linux-2.4.26/fs/block_dev.c 2004-06-07 19:36:15.000000000 +0100 | |
63 | @@ -13,6 +13,7 @@ | |
64 | #include <linux/slab.h> | |
65 | #include <linux/kmod.h> | |
66 | #include <linux/major.h> | |
67 | +#include <linux/kernel_stat.h> | |
68 | #include <linux/devfs_fs_kernel.h> | |
69 | #include <linux/smp_lock.h> | |
70 | #include <linux/iobuf.h> | |
71 | @@ -465,11 +466,52 @@ | |
72 | return ret; | |
73 | } | |
74 | ||
75 | +/* | |
76 | + * Allocate a statistics structure for the give device | |
77 | + */ | |
78 | + | |
79 | +static int alloc_dk_stat(unsigned int major) | |
80 | +{ | |
81 | + dk_stat_t * new; | |
82 | + | |
83 | + /*allocate space for statistics */ | |
84 | + if (kstat.dk_drive_info[major] != NULL) { | |
85 | + printk(KERN_WARNING "register_blkdev: stat struct" | |
86 | + " for device %d exists before register\n", | |
87 | + major); | |
88 | + } else { | |
89 | + int size = sizeof(dk_stat_t) * DK_MAX_DISK; | |
90 | + new = (dk_stat_t *)kmalloc(size, GFP_KERNEL); | |
91 | + if (new == NULL) { | |
92 | + return -ENOMEM; | |
93 | + } | |
94 | + memset(new, 0, size); | |
95 | + kstat.dk_drive_info[major] = new; | |
96 | + } | |
97 | + return 0; | |
98 | +} | |
99 | + | |
100 | +static void free_dk_stat(unsigned int major) | |
101 | +{ | |
102 | + dk_stat_t * ds; | |
103 | + | |
104 | + ds = kstat.dk_drive_info[major]; | |
105 | + kstat.dk_drive_info[major] = NULL; | |
106 | + | |
107 | + if (ds != NULL) | |
108 | + kfree(ds); | |
109 | +} | |
110 | + | |
111 | int register_blkdev(unsigned int major, const char * name, struct block_device_operations *bdops) | |
112 | { | |
113 | + int err; | |
114 | + | |
115 | if (major == 0) { | |
116 | for (major = MAX_BLKDEV-1; major > 0; major--) { | |
117 | if (blkdevs[major].bdops == NULL) { | |
118 | + err = alloc_dk_stat(major); | |
119 | + if (err != 0) | |
120 | + return err; | |
121 | blkdevs[major].name = name; | |
122 | blkdevs[major].bdops = bdops; | |
123 | return major; | |
124 | @@ -481,8 +523,13 @@ | |
125 | return -EINVAL; | |
126 | if (blkdevs[major].bdops && blkdevs[major].bdops != bdops) | |
127 | return -EBUSY; | |
128 | + | |
129 | + err = alloc_dk_stat(major); | |
130 | + if (err != 0) | |
131 | + return err; | |
132 | blkdevs[major].name = name; | |
133 | blkdevs[major].bdops = bdops; | |
134 | + | |
135 | return 0; | |
136 | } | |
137 | ||
138 | @@ -496,6 +543,9 @@ | |
139 | return -EINVAL; | |
140 | blkdevs[major].name = NULL; | |
141 | blkdevs[major].bdops = NULL; | |
142 | + | |
143 | + /* free statistic structure */ | |
144 | + free_dk_stat(major); | |
145 | return 0; | |
146 | } | |
147 | ||
148 | diff -ur g/linux-2.4.26/fs/proc/proc_misc.c h/linux-2.4.26/fs/proc/proc_misc.c | |
149 | --- g/linux-2.4.26/fs/proc/proc_misc.c 2003-11-28 18:26:21.000000000 +0000 | |
150 | +++ h/linux-2.4.26/fs/proc/proc_misc.c 2004-06-07 19:37:08.000000000 +0100 | |
151 | @@ -355,23 +355,28 @@ | |
152 | ||
153 | proc_sprintf(page, &off, &len, "\ndisk_io: "); | |
154 | ||
155 | - for (major = 0; major < DK_MAX_MAJOR; major++) { | |
156 | - for (disk = 0; disk < DK_MAX_DISK; disk++) { | |
157 | - int active = kstat.dk_drive[major][disk] + | |
158 | - kstat.dk_drive_rblk[major][disk] + | |
159 | - kstat.dk_drive_wblk[major][disk]; | |
160 | + for (major = 0; major < MAX_BLKDEV; major++) { | |
161 | + if ( kstat.dk_drive_info[major] == NULL) | |
162 | + continue; | |
163 | + for (disk = 0; disk < DK_MAX_DISK; disk++) { | |
164 | + dk_stat_t * ds; | |
165 | + int active; | |
166 | + | |
167 | + ds = kstat.dk_drive_info[major] + disk; | |
168 | + active = ds->dk_drive_rio + ds->dk_drive_wio + | |
169 | + ds->dk_drive_rblk + ds->dk_drive_wblk; | |
170 | if (active) | |
171 | proc_sprintf(page, &off, &len, | |
172 | "(%u,%u):(%u,%u,%u,%u,%u) ", | |
173 | - major, disk, | |
174 | - kstat.dk_drive[major][disk], | |
175 | - kstat.dk_drive_rio[major][disk], | |
176 | - kstat.dk_drive_rblk[major][disk], | |
177 | - kstat.dk_drive_wio[major][disk], | |
178 | - kstat.dk_drive_wblk[major][disk] | |
179 | - ); | |
180 | - } | |
181 | - } | |
182 | + major, disk, | |
183 | + ds->dk_drive_rio + ds->dk_drive_wio, | |
184 | + ds->dk_drive_rio, | |
185 | + ds->dk_drive_rblk, | |
186 | + ds->dk_drive_wio, | |
187 | + ds->dk_drive_wblk | |
188 | + ); | |
189 | + } | |
190 | + } | |
191 | ||
192 | proc_sprintf(page, &off, &len, | |
193 | "\nctxt %u\n" | |
194 | diff -ur g/linux-2.4.26/include/linux/genhd.h h/linux-2.4.26/include/linux/genhd.h | |
195 | --- g/linux-2.4.26/include/linux/genhd.h 2002-11-28 23:53:15.000000000 +0000 | |
196 | +++ h/linux-2.4.26/include/linux/genhd.h 2004-06-07 19:36:15.000000000 +0100 | |
197 | @@ -294,21 +294,30 @@ | |
198 | unsigned int index; | |
199 | ||
200 | switch (major) { | |
201 | - case DAC960_MAJOR+0: | |
202 | - index = (minor & 0x00f8) >> 3; | |
203 | - break; | |
204 | case SCSI_DISK0_MAJOR: | |
205 | index = (minor & 0x00f0) >> 4; | |
206 | break; | |
207 | case IDE0_MAJOR: /* same as HD_MAJOR */ | |
208 | case XT_DISK_MAJOR: | |
209 | + case IDE1_MAJOR: | |
210 | + case IDE2_MAJOR: | |
211 | + case IDE3_MAJOR: | |
212 | + case IDE4_MAJOR: | |
213 | + case IDE5_MAJOR: | |
214 | index = (minor & 0x0040) >> 6; | |
215 | break; | |
216 | - case IDE1_MAJOR: | |
217 | - index = ((minor & 0x0040) >> 6) + 2; | |
218 | + case SCSI_CDROM_MAJOR: | |
219 | + index = minor & 0x000f; | |
220 | break; | |
221 | default: | |
222 | - return 0; | |
223 | + if (major >= SCSI_DISK1_MAJOR && major <= SCSI_DISK7_MAJOR) | |
224 | + index = (minor & 0x00f0) >> 4; | |
225 | + else if (major >= DAC960_MAJOR && major <= DAC960_MAJOR + 7) | |
226 | + index = (minor & 0x00f8) >> 3; | |
227 | + else if (major >= IDE6_MAJOR && major <= IDE9_MAJOR) | |
228 | + index = (minor & 0x0040) >> 6; | |
229 | + else | |
230 | + return 0; | |
231 | } | |
232 | return index; | |
233 | } | |
234 | diff -ur g/linux-2.4.26/include/linux/kernel_stat.h h/linux-2.4.26/include/linux/kernel_stat.h | |
235 | --- g/linux-2.4.26/include/linux/kernel_stat.h 2003-06-13 15:51:38.000000000 +0100 | |
236 | +++ h/linux-2.4.26/include/linux/kernel_stat.h 2004-06-07 19:36:15.000000000 +0100 | |
237 | @@ -5,6 +5,7 @@ | |
238 | #include <asm/irq.h> | |
239 | #include <linux/smp.h> | |
240 | #include <linux/threads.h> | |
241 | +#include <linux/major.h> | |
242 | ||
243 | /* | |
244 | * 'kernel_stat.h' contains the definitions needed for doing | |
245 | @@ -15,15 +15,19 @@ | |
246 | #define DK_MAX_MAJOR 16 | |
247 | #define DK_MAX_DISK 16 | |
248 | ||
249 | +struct dk_stat{ | |
250 | + unsigned int dk_drive_rio; | |
251 | + unsigned int dk_drive_wio; | |
252 | + unsigned int dk_drive_rblk; | |
253 | + unsigned int dk_drive_wblk; | |
254 | +}; | |
255 | + | |
256 | +typedef struct dk_stat dk_stat_t; | |
257 | struct kernel_stat { | |
258 | unsigned int per_cpu_user[NR_CPUS], | |
259 | per_cpu_nice[NR_CPUS], | |
260 | per_cpu_system[NR_CPUS]; | |
261 | - unsigned int dk_drive[DK_MAX_MAJOR][DK_MAX_DISK]; | |
262 | - unsigned int dk_drive_rio[DK_MAX_MAJOR][DK_MAX_DISK]; | |
263 | - unsigned int dk_drive_wio[DK_MAX_MAJOR][DK_MAX_DISK]; | |
264 | - unsigned int dk_drive_rblk[DK_MAX_MAJOR][DK_MAX_DISK]; | |
265 | - unsigned int dk_drive_wblk[DK_MAX_MAJOR][DK_MAX_DISK]; | |
266 | + dk_stat_t *dk_drive_info[MAX_BLKDEV]; | |
267 | unsigned int pgpgin, pgpgout; | |
268 | unsigned int pswpin, pswpout; | |
269 | #if defined (__hppa__) |