diff options
Diffstat (limited to 'block/genhd.c')
-rw-r--r-- | block/genhd.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/block/genhd.c b/block/genhd.c index f4c64c2b303a..5b76bf55d05c 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -869,6 +869,7 @@ static DEVICE_ATTR(size, S_IRUGO, part_size_show, NULL); | |||
869 | static DEVICE_ATTR(alignment_offset, S_IRUGO, disk_alignment_offset_show, NULL); | 869 | static DEVICE_ATTR(alignment_offset, S_IRUGO, disk_alignment_offset_show, NULL); |
870 | static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL); | 870 | static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL); |
871 | static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); | 871 | static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL); |
872 | static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL); | ||
872 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 873 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
873 | static struct device_attribute dev_attr_fail = | 874 | static struct device_attribute dev_attr_fail = |
874 | __ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store); | 875 | __ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store); |
@@ -888,6 +889,7 @@ static struct attribute *disk_attrs[] = { | |||
888 | &dev_attr_alignment_offset.attr, | 889 | &dev_attr_alignment_offset.attr, |
889 | &dev_attr_capability.attr, | 890 | &dev_attr_capability.attr, |
890 | &dev_attr_stat.attr, | 891 | &dev_attr_stat.attr, |
892 | &dev_attr_inflight.attr, | ||
891 | #ifdef CONFIG_FAIL_MAKE_REQUEST | 893 | #ifdef CONFIG_FAIL_MAKE_REQUEST |
892 | &dev_attr_fail.attr, | 894 | &dev_attr_fail.attr, |
893 | #endif | 895 | #endif |
@@ -1053,7 +1055,7 @@ static int diskstats_show(struct seq_file *seqf, void *v) | |||
1053 | part_stat_read(hd, merges[1]), | 1055 | part_stat_read(hd, merges[1]), |
1054 | (unsigned long long)part_stat_read(hd, sectors[1]), | 1056 | (unsigned long long)part_stat_read(hd, sectors[1]), |
1055 | jiffies_to_msecs(part_stat_read(hd, ticks[1])), | 1057 | jiffies_to_msecs(part_stat_read(hd, ticks[1])), |
1056 | hd->in_flight, | 1058 | part_in_flight(hd), |
1057 | jiffies_to_msecs(part_stat_read(hd, io_ticks)), | 1059 | jiffies_to_msecs(part_stat_read(hd, io_ticks)), |
1058 | jiffies_to_msecs(part_stat_read(hd, time_in_queue)) | 1060 | jiffies_to_msecs(part_stat_read(hd, time_in_queue)) |
1059 | ); | 1061 | ); |
@@ -1215,6 +1217,16 @@ void put_disk(struct gendisk *disk) | |||
1215 | 1217 | ||
1216 | EXPORT_SYMBOL(put_disk); | 1218 | EXPORT_SYMBOL(put_disk); |
1217 | 1219 | ||
1220 | static void set_disk_ro_uevent(struct gendisk *gd, int ro) | ||
1221 | { | ||
1222 | char event[] = "DISK_RO=1"; | ||
1223 | char *envp[] = { event, NULL }; | ||
1224 | |||
1225 | if (!ro) | ||
1226 | event[8] = '0'; | ||
1227 | kobject_uevent_env(&disk_to_dev(gd)->kobj, KOBJ_CHANGE, envp); | ||
1228 | } | ||
1229 | |||
1218 | void set_device_ro(struct block_device *bdev, int flag) | 1230 | void set_device_ro(struct block_device *bdev, int flag) |
1219 | { | 1231 | { |
1220 | bdev->bd_part->policy = flag; | 1232 | bdev->bd_part->policy = flag; |
@@ -1227,8 +1239,12 @@ void set_disk_ro(struct gendisk *disk, int flag) | |||
1227 | struct disk_part_iter piter; | 1239 | struct disk_part_iter piter; |
1228 | struct hd_struct *part; | 1240 | struct hd_struct *part; |
1229 | 1241 | ||
1230 | disk_part_iter_init(&piter, disk, | 1242 | if (disk->part0.policy != flag) { |
1231 | DISK_PITER_INCL_EMPTY | DISK_PITER_INCL_PART0); | 1243 | set_disk_ro_uevent(disk, flag); |
1244 | disk->part0.policy = flag; | ||
1245 | } | ||
1246 | |||
1247 | disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY); | ||
1232 | while ((part = disk_part_iter_next(&piter))) | 1248 | while ((part = disk_part_iter_next(&piter))) |
1233 | part->policy = flag; | 1249 | part->policy = flag; |
1234 | disk_part_iter_exit(&piter); | 1250 | disk_part_iter_exit(&piter); |