aboutsummaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-08-25 06:56:10 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 02:56:07 -0400
commitb7db9956e57c8151b930d5e5fe5c766e6aad3ff7 (patch)
treed663a8687fff481abb1498c2ea0eac01ef81cb26 /block/genhd.c
parente56105214943ce5f0901d20e972a7cfd0d1d0656 (diff)
block: move policy from disk to part0
Move disk->policy to part0->policy. Implement and use get_disk_ro(). Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/genhd.c')
-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);