aboutsummaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
Diffstat (limited to 'block')
-rw-r--r--block/genhd.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/block/genhd.c b/block/genhd.c
index c70db35076a0..70358f3c7423 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -757,7 +757,7 @@ static ssize_t disk_ro_show(struct device *dev,
757{ 757{
758 struct gendisk *disk = dev_to_disk(dev); 758 struct gendisk *disk = dev_to_disk(dev);
759 759
760 return sprintf(buf, "%d\n", disk->policy ? 1 : 0); 760 return sprintf(buf, "%d\n", get_disk_ro(disk) ? 1 : 0);
761} 761}
762 762
763static ssize_t disk_capability_show(struct device *dev, 763static ssize_t disk_capability_show(struct device *dev,
@@ -1090,10 +1090,7 @@ EXPORT_SYMBOL(put_disk);
1090 1090
1091void set_device_ro(struct block_device *bdev, int flag) 1091void set_device_ro(struct block_device *bdev, int flag)
1092{ 1092{
1093 if (bdev->bd_contains != bdev) 1093 bdev->bd_part->policy = flag;
1094 bdev->bd_part->policy = flag;
1095 else
1096 bdev->bd_disk->policy = flag;
1097} 1094}
1098 1095
1099EXPORT_SYMBOL(set_device_ro); 1096EXPORT_SYMBOL(set_device_ro);
@@ -1103,8 +1100,8 @@ void set_disk_ro(struct gendisk *disk, int flag)
1103 struct disk_part_iter piter; 1100 struct disk_part_iter piter;
1104 struct hd_struct *part; 1101 struct hd_struct *part;
1105 1102
1106 disk->policy = flag; 1103 disk_part_iter_init(&piter, disk,
1107 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY); 1104 DISK_PITER_INCL_EMPTY | DISK_PITER_INCL_PART0);
1108 while ((part = disk_part_iter_next(&piter))) 1105 while ((part = disk_part_iter_next(&piter)))
1109 part->policy = flag; 1106 part->policy = flag;
1110 disk_part_iter_exit(&piter); 1107 disk_part_iter_exit(&piter);
@@ -1116,10 +1113,7 @@ int bdev_read_only(struct block_device *bdev)
1116{ 1113{
1117 if (!bdev) 1114 if (!bdev)
1118 return 0; 1115 return 0;
1119 else if (bdev->bd_contains != bdev) 1116 return bdev->bd_part->policy;
1120 return bdev->bd_part->policy;
1121 else
1122 return bdev->bd_disk->policy;
1123} 1117}
1124 1118
1125EXPORT_SYMBOL(bdev_read_only); 1119EXPORT_SYMBOL(bdev_read_only);