aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions/check.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/partitions/check.c')
-rw-r--r--fs/partitions/check.c48
1 files changed, 36 insertions, 12 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 739da701ae7b..03f808c5b79d 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -18,6 +18,7 @@
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/kmod.h> 19#include <linux/kmod.h>
20#include <linux/ctype.h> 20#include <linux/ctype.h>
21#include <linux/genhd.h>
21 22
22#include "check.h" 23#include "check.h"
23 24
@@ -215,9 +216,25 @@ static ssize_t part_stat_show(struct device *dev,
215{ 216{
216 struct hd_struct *p = dev_to_part(dev); 217 struct hd_struct *p = dev_to_part(dev);
217 218
218 return sprintf(buf, "%8u %8llu %8u %8llu\n", 219 preempt_disable();
219 p->ios[0], (unsigned long long)p->sectors[0], 220 part_round_stats(p);
220 p->ios[1], (unsigned long long)p->sectors[1]); 221 preempt_enable();
222 return sprintf(buf,
223 "%8lu %8lu %8llu %8u "
224 "%8lu %8lu %8llu %8u "
225 "%8u %8u %8u"
226 "\n",
227 part_stat_read(p, ios[READ]),
228 part_stat_read(p, merges[READ]),
229 (unsigned long long)part_stat_read(p, sectors[READ]),
230 jiffies_to_msecs(part_stat_read(p, ticks[READ])),
231 part_stat_read(p, ios[WRITE]),
232 part_stat_read(p, merges[WRITE]),
233 (unsigned long long)part_stat_read(p, sectors[WRITE]),
234 jiffies_to_msecs(part_stat_read(p, ticks[WRITE])),
235 p->in_flight,
236 jiffies_to_msecs(part_stat_read(p, io_ticks)),
237 jiffies_to_msecs(part_stat_read(p, time_in_queue)));
221} 238}
222 239
223#ifdef CONFIG_FAIL_MAKE_REQUEST 240#ifdef CONFIG_FAIL_MAKE_REQUEST
@@ -273,6 +290,7 @@ static struct attribute_group *part_attr_groups[] = {
273static void part_release(struct device *dev) 290static void part_release(struct device *dev)
274{ 291{
275 struct hd_struct *p = dev_to_part(dev); 292 struct hd_struct *p = dev_to_part(dev);
293 free_part_stats(p);
276 kfree(p); 294 kfree(p);
277} 295}
278 296
@@ -312,13 +330,20 @@ void delete_partition(struct gendisk *disk, int part)
312 disk->part[part-1] = NULL; 330 disk->part[part-1] = NULL;
313 p->start_sect = 0; 331 p->start_sect = 0;
314 p->nr_sects = 0; 332 p->nr_sects = 0;
315 p->ios[0] = p->ios[1] = 0; 333 part_stat_set_all(p, 0);
316 p->sectors[0] = p->sectors[1] = 0;
317 kobject_put(p->holder_dir); 334 kobject_put(p->holder_dir);
318 device_del(&p->dev); 335 device_del(&p->dev);
319 put_device(&p->dev); 336 put_device(&p->dev);
320} 337}
321 338
339static ssize_t whole_disk_show(struct device *dev,
340 struct device_attribute *attr, char *buf)
341{
342 return 0;
343}
344static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
345 whole_disk_show, NULL);
346
322void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags) 347void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags)
323{ 348{
324 struct hd_struct *p; 349 struct hd_struct *p;
@@ -328,6 +353,10 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
328 if (!p) 353 if (!p)
329 return; 354 return;
330 355
356 if (!init_part_stats(p)) {
357 kfree(p);
358 return;
359 }
331 p->start_sect = start; 360 p->start_sect = start;
332 p->nr_sects = len; 361 p->nr_sects = len;
333 p->partno = part; 362 p->partno = part;
@@ -352,13 +381,8 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
352 device_add(&p->dev); 381 device_add(&p->dev);
353 partition_sysfs_add_subdir(p); 382 partition_sysfs_add_subdir(p);
354 p->dev.uevent_suppress = 0; 383 p->dev.uevent_suppress = 0;
355 if (flags & ADDPART_FLAG_WHOLEDISK) { 384 if (flags & ADDPART_FLAG_WHOLEDISK)
356 static struct attribute addpartattr = { 385 err = device_create_file(&p->dev, &dev_attr_whole_disk);
357 .name = "whole_disk",
358 .mode = S_IRUSR | S_IRGRP | S_IROTH,
359 };
360 err = sysfs_create_file(&p->dev.kobj, &addpartattr);
361 }
362 386
363 /* suppress uevent if the disk supresses it */ 387 /* suppress uevent if the disk supresses it */
364 if (!disk->dev.uevent_suppress) 388 if (!disk->dev.uevent_suppress)