diff options
Diffstat (limited to 'drivers/s390/block/dasd_proc.c')
-rw-r--r-- | drivers/s390/block/dasd_proc.c | 109 |
1 files changed, 50 insertions, 59 deletions
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c index 71f95f54866f..f13a0bdd148c 100644 --- a/drivers/s390/block/dasd_proc.c +++ b/drivers/s390/block/dasd_proc.c | |||
@@ -165,51 +165,32 @@ static const struct file_operations dasd_devices_file_ops = { | |||
165 | .release = seq_release, | 165 | .release = seq_release, |
166 | }; | 166 | }; |
167 | 167 | ||
168 | static int | ||
169 | dasd_calc_metrics(char *page, char **start, off_t off, | ||
170 | int count, int *eof, int len) | ||
171 | { | ||
172 | len = (len > off) ? len - off : 0; | ||
173 | if (len > count) | ||
174 | len = count; | ||
175 | if (len < count) | ||
176 | *eof = 1; | ||
177 | *start = page + off; | ||
178 | return len; | ||
179 | } | ||
180 | |||
181 | #ifdef CONFIG_DASD_PROFILE | 168 | #ifdef CONFIG_DASD_PROFILE |
182 | static char * | 169 | static void dasd_statistics_array(struct seq_file *m, unsigned int *array, int factor) |
183 | dasd_statistics_array(char *str, unsigned int *array, int factor) | ||
184 | { | 170 | { |
185 | int i; | 171 | int i; |
186 | 172 | ||
187 | for (i = 0; i < 32; i++) { | 173 | for (i = 0; i < 32; i++) { |
188 | str += sprintf(str, "%7d ", array[i] / factor); | 174 | seq_printf(m, "%7d ", array[i] / factor); |
189 | if (i == 15) | 175 | if (i == 15) |
190 | str += sprintf(str, "\n"); | 176 | seq_putc(m, '\n'); |
191 | } | 177 | } |
192 | str += sprintf(str,"\n"); | 178 | seq_putc(m, '\n'); |
193 | return str; | ||
194 | } | 179 | } |
195 | #endif /* CONFIG_DASD_PROFILE */ | 180 | #endif /* CONFIG_DASD_PROFILE */ |
196 | 181 | ||
197 | static int | 182 | static int dasd_stats_proc_show(struct seq_file *m, void *v) |
198 | dasd_statistics_read(char *page, char **start, off_t off, | ||
199 | int count, int *eof, void *data) | ||
200 | { | 183 | { |
201 | unsigned long len; | ||
202 | #ifdef CONFIG_DASD_PROFILE | 184 | #ifdef CONFIG_DASD_PROFILE |
203 | struct dasd_profile_info_t *prof; | 185 | struct dasd_profile_info_t *prof; |
204 | char *str; | ||
205 | int factor; | 186 | int factor; |
206 | 187 | ||
207 | /* check for active profiling */ | 188 | /* check for active profiling */ |
208 | if (dasd_profile_level == DASD_PROFILE_OFF) { | 189 | if (dasd_profile_level == DASD_PROFILE_OFF) { |
209 | len = sprintf(page, "Statistics are off - they might be " | 190 | seq_printf(m, "Statistics are off - they might be " |
210 | "switched on using 'echo set on > " | 191 | "switched on using 'echo set on > " |
211 | "/proc/dasd/statistics'\n"); | 192 | "/proc/dasd/statistics'\n"); |
212 | return dasd_calc_metrics(page, start, off, count, eof, len); | 193 | return 0; |
213 | } | 194 | } |
214 | 195 | ||
215 | prof = &dasd_global_profile; | 196 | prof = &dasd_global_profile; |
@@ -217,47 +198,49 @@ dasd_statistics_read(char *page, char **start, off_t off, | |||
217 | for (factor = 1; (prof->dasd_io_reqs / factor) > 9999999; | 198 | for (factor = 1; (prof->dasd_io_reqs / factor) > 9999999; |
218 | factor *= 10); | 199 | factor *= 10); |
219 | 200 | ||
220 | str = page; | 201 | seq_printf(m, "%d dasd I/O requests\n", prof->dasd_io_reqs); |
221 | str += sprintf(str, "%d dasd I/O requests\n", prof->dasd_io_reqs); | 202 | seq_printf(m, "with %u sectors(512B each)\n", |
222 | str += sprintf(str, "with %u sectors(512B each)\n", | ||
223 | prof->dasd_io_sects); | 203 | prof->dasd_io_sects); |
224 | str += sprintf(str, "Scale Factor is %d\n", factor); | 204 | seq_printf(m, "Scale Factor is %d\n", factor); |
225 | str += sprintf(str, | 205 | seq_printf(m, |
226 | " __<4 ___8 __16 __32 __64 _128 " | 206 | " __<4 ___8 __16 __32 __64 _128 " |
227 | " _256 _512 __1k __2k __4k __8k " | 207 | " _256 _512 __1k __2k __4k __8k " |
228 | " _16k _32k _64k 128k\n"); | 208 | " _16k _32k _64k 128k\n"); |
229 | str += sprintf(str, | 209 | seq_printf(m, |
230 | " _256 _512 __1M __2M __4M __8M " | 210 | " _256 _512 __1M __2M __4M __8M " |
231 | " _16M _32M _64M 128M 256M 512M " | 211 | " _16M _32M _64M 128M 256M 512M " |
232 | " __1G __2G __4G " " _>4G\n"); | 212 | " __1G __2G __4G " " _>4G\n"); |
233 | 213 | ||
234 | str += sprintf(str, "Histogram of sizes (512B secs)\n"); | 214 | seq_printf(m, "Histogram of sizes (512B secs)\n"); |
235 | str = dasd_statistics_array(str, prof->dasd_io_secs, factor); | 215 | dasd_statistics_array(m, prof->dasd_io_secs, factor); |
236 | str += sprintf(str, "Histogram of I/O times (microseconds)\n"); | 216 | seq_printf(m, "Histogram of I/O times (microseconds)\n"); |
237 | str = dasd_statistics_array(str, prof->dasd_io_times, factor); | 217 | dasd_statistics_array(m, prof->dasd_io_times, factor); |
238 | str += sprintf(str, "Histogram of I/O times per sector\n"); | 218 | seq_printf(m, "Histogram of I/O times per sector\n"); |
239 | str = dasd_statistics_array(str, prof->dasd_io_timps, factor); | 219 | dasd_statistics_array(m, prof->dasd_io_timps, factor); |
240 | str += sprintf(str, "Histogram of I/O time till ssch\n"); | 220 | seq_printf(m, "Histogram of I/O time till ssch\n"); |
241 | str = dasd_statistics_array(str, prof->dasd_io_time1, factor); | 221 | dasd_statistics_array(m, prof->dasd_io_time1, factor); |
242 | str += sprintf(str, "Histogram of I/O time between ssch and irq\n"); | 222 | seq_printf(m, "Histogram of I/O time between ssch and irq\n"); |
243 | str = dasd_statistics_array(str, prof->dasd_io_time2, factor); | 223 | dasd_statistics_array(m, prof->dasd_io_time2, factor); |
244 | str += sprintf(str, "Histogram of I/O time between ssch " | 224 | seq_printf(m, "Histogram of I/O time between ssch " |
245 | "and irq per sector\n"); | 225 | "and irq per sector\n"); |
246 | str = dasd_statistics_array(str, prof->dasd_io_time2ps, factor); | 226 | dasd_statistics_array(m, prof->dasd_io_time2ps, factor); |
247 | str += sprintf(str, "Histogram of I/O time between irq and end\n"); | 227 | seq_printf(m, "Histogram of I/O time between irq and end\n"); |
248 | str = dasd_statistics_array(str, prof->dasd_io_time3, factor); | 228 | dasd_statistics_array(m, prof->dasd_io_time3, factor); |
249 | str += sprintf(str, "# of req in chanq at enqueuing (1..32) \n"); | 229 | seq_printf(m, "# of req in chanq at enqueuing (1..32) \n"); |
250 | str = dasd_statistics_array(str, prof->dasd_io_nr_req, factor); | 230 | dasd_statistics_array(m, prof->dasd_io_nr_req, factor); |
251 | len = str - page; | ||
252 | #else | 231 | #else |
253 | len = sprintf(page, "Statistics are not activated in this kernel\n"); | 232 | seq_printf(m, "Statistics are not activated in this kernel\n"); |
254 | #endif | 233 | #endif |
255 | return dasd_calc_metrics(page, start, off, count, eof, len); | 234 | return 0; |
256 | } | 235 | } |
257 | 236 | ||
258 | static int | 237 | static int dasd_stats_proc_open(struct inode *inode, struct file *file) |
259 | dasd_statistics_write(struct file *file, const char __user *user_buf, | 238 | { |
260 | unsigned long user_len, void *data) | 239 | return single_open(file, dasd_stats_proc_show, NULL); |
240 | } | ||
241 | |||
242 | static ssize_t dasd_stats_proc_write(struct file *file, | ||
243 | const char __user *user_buf, size_t user_len, loff_t *pos) | ||
261 | { | 244 | { |
262 | #ifdef CONFIG_DASD_PROFILE | 245 | #ifdef CONFIG_DASD_PROFILE |
263 | char *buffer, *str; | 246 | char *buffer, *str; |
@@ -308,6 +291,15 @@ out_error: | |||
308 | #endif /* CONFIG_DASD_PROFILE */ | 291 | #endif /* CONFIG_DASD_PROFILE */ |
309 | } | 292 | } |
310 | 293 | ||
294 | static const struct file_operations dasd_stats_proc_fops = { | ||
295 | .owner = THIS_MODULE, | ||
296 | .open = dasd_stats_proc_open, | ||
297 | .read = seq_read, | ||
298 | .llseek = seq_lseek, | ||
299 | .release = single_release, | ||
300 | .write = dasd_stats_proc_write, | ||
301 | }; | ||
302 | |||
311 | /* | 303 | /* |
312 | * Create dasd proc-fs entries. | 304 | * Create dasd proc-fs entries. |
313 | * In case creation failed, cleanup and return -ENOENT. | 305 | * In case creation failed, cleanup and return -ENOENT. |
@@ -324,13 +316,12 @@ dasd_proc_init(void) | |||
324 | &dasd_devices_file_ops); | 316 | &dasd_devices_file_ops); |
325 | if (!dasd_devices_entry) | 317 | if (!dasd_devices_entry) |
326 | goto out_nodevices; | 318 | goto out_nodevices; |
327 | dasd_statistics_entry = create_proc_entry("statistics", | 319 | dasd_statistics_entry = proc_create("statistics", |
328 | S_IFREG | S_IRUGO | S_IWUSR, | 320 | S_IFREG | S_IRUGO | S_IWUSR, |
329 | dasd_proc_root_entry); | 321 | dasd_proc_root_entry, |
322 | &dasd_stats_proc_fops); | ||
330 | if (!dasd_statistics_entry) | 323 | if (!dasd_statistics_entry) |
331 | goto out_nostatistics; | 324 | goto out_nostatistics; |
332 | dasd_statistics_entry->read_proc = dasd_statistics_read; | ||
333 | dasd_statistics_entry->write_proc = dasd_statistics_write; | ||
334 | return 0; | 325 | return 0; |
335 | 326 | ||
336 | out_nostatistics: | 327 | out_nostatistics: |