diff options
author | Tejun Heo <tj@kernel.org> | 2008-08-25 06:56:10 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-09 02:56:07 -0400 |
commit | b7db9956e57c8151b930d5e5fe5c766e6aad3ff7 (patch) | |
tree | d663a8687fff481abb1498c2ea0eac01ef81cb26 | |
parent | e56105214943ce5f0901d20e972a7cfd0d1d0656 (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>
-rw-r--r-- | block/genhd.c | 16 | ||||
-rw-r--r-- | drivers/ide/ide-cd.c | 2 | ||||
-rw-r--r-- | drivers/md/dm-ioctl.c | 2 | ||||
-rw-r--r-- | fs/partitions/check.c | 2 | ||||
-rw-r--r-- | include/linux/genhd.h | 6 |
5 files changed, 13 insertions, 15 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 | ||
763 | static ssize_t disk_capability_show(struct device *dev, | 763 | static ssize_t disk_capability_show(struct device *dev, |
@@ -1090,10 +1090,7 @@ EXPORT_SYMBOL(put_disk); | |||
1090 | 1090 | ||
1091 | void set_device_ro(struct block_device *bdev, int flag) | 1091 | void 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 | ||
1099 | EXPORT_SYMBOL(set_device_ro); | 1096 | EXPORT_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 | ||
1125 | EXPORT_SYMBOL(bdev_read_only); | 1119 | EXPORT_SYMBOL(bdev_read_only); |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index f16bb4667238..03c2cb6a58bc 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1113,7 +1113,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1113 | 1113 | ||
1114 | if (write) { | 1114 | if (write) { |
1115 | /* disk has become write protected */ | 1115 | /* disk has become write protected */ |
1116 | if (cd->disk->policy) { | 1116 | if (get_disk_ro(cd->disk)) { |
1117 | cdrom_end_request(drive, 0); | 1117 | cdrom_end_request(drive, 0); |
1118 | return ide_stopped; | 1118 | return ide_stopped; |
1119 | } | 1119 | } |
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index c3de311117a1..5b919159f084 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -548,7 +548,7 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param) | |||
548 | */ | 548 | */ |
549 | param->open_count = dm_open_count(md); | 549 | param->open_count = dm_open_count(md); |
550 | 550 | ||
551 | if (disk->policy) | 551 | if (get_disk_ro(disk)) |
552 | param->flags |= DM_READONLY_FLAG; | 552 | param->flags |= DM_READONLY_FLAG; |
553 | 553 | ||
554 | param->event_nr = dm_get_event_nr(md); | 554 | param->event_nr = dm_get_event_nr(md); |
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index 24d2c56d7d2d..ace6d03602c7 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -375,7 +375,7 @@ int add_partition(struct gendisk *disk, int partno, | |||
375 | p->start_sect = start; | 375 | p->start_sect = start; |
376 | p->nr_sects = len; | 376 | p->nr_sects = len; |
377 | p->partno = partno; | 377 | p->partno = partno; |
378 | p->policy = disk->policy; | 378 | p->policy = get_disk_ro(disk); |
379 | 379 | ||
380 | dname = dev_name(ddev); | 380 | dname = dev_name(ddev); |
381 | if (isdigit(dname[strlen(dname) - 1])) | 381 | if (isdigit(dname[strlen(dname) - 1])) |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 9cb8380cf0eb..4411bdd671dd 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -145,7 +145,6 @@ struct gendisk { | |||
145 | struct kobject *slave_dir; | 145 | struct kobject *slave_dir; |
146 | 146 | ||
147 | struct timer_rand_state *random; | 147 | struct timer_rand_state *random; |
148 | int policy; | ||
149 | 148 | ||
150 | atomic_t sync_io; /* RAID */ | 149 | atomic_t sync_io; /* RAID */ |
151 | unsigned long stamp; | 150 | unsigned long stamp; |
@@ -403,6 +402,11 @@ extern struct block_device *bdget_disk(struct gendisk *disk, int partno); | |||
403 | extern void set_device_ro(struct block_device *bdev, int flag); | 402 | extern void set_device_ro(struct block_device *bdev, int flag); |
404 | extern void set_disk_ro(struct gendisk *disk, int flag); | 403 | extern void set_disk_ro(struct gendisk *disk, int flag); |
405 | 404 | ||
405 | static inline int get_disk_ro(struct gendisk *disk) | ||
406 | { | ||
407 | return disk->part0.policy; | ||
408 | } | ||
409 | |||
406 | /* drivers/char/random.c */ | 410 | /* drivers/char/random.c */ |
407 | extern void add_disk_randomness(struct gendisk *disk); | 411 | extern void add_disk_randomness(struct gendisk *disk); |
408 | extern void rand_initialize_disk(struct gendisk *disk); | 412 | extern void rand_initialize_disk(struct gendisk *disk); |