aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-09-03 03:06:42 -0400
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 02:56:07 -0400
commitb5d0b9df0ba5d9a044f3a21e7544f53d90bd1465 (patch)
treed3347c1cfc59cf5d38c2c9adc2423f9d9b4cf818 /fs
parented9e1982347b36573cd622ee5f4e2a7ccd79b3fd (diff)
block: introduce partition 0
genhd and partition code handled disk and partitions separately. All information about the whole disk was in struct genhd and partitions in struct hd_struct. However, the whole disk (part0) and other partitions have a lot in common and the data structures end up having good number of common fields and thus separate code paths doing the same thing. Also, the partition array was indexed by partno - 1 which gets pretty confusing at times. This patch introduces partition 0 and makes the partition array indexed by partno. Following patches will unify the handling of disk and parts piece-by-piece. This patch also implements disk_partitionable() which tests whether a disk is partitionable. With coming dynamic partition array change, the most common usage of disk_max_parts() will be testing whether a disk is partitionable and the number of max partitions will become much less important. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/block_dev.c2
-rw-r--r--fs/partitions/check.c12
2 files changed, 7 insertions, 7 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index a02df22f37c3..c982a9107979 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -892,7 +892,7 @@ int check_disk_change(struct block_device *bdev)
892 892
893 if (bdops->revalidate_disk) 893 if (bdops->revalidate_disk)
894 bdops->revalidate_disk(bdev->bd_disk); 894 bdops->revalidate_disk(bdev->bd_disk);
895 if (disk_max_parts(bdev->bd_disk)) 895 if (disk_partitionable(bdev->bd_disk))
896 bdev->bd_invalidated = 1; 896 bdev->bd_invalidated = 1;
897 return 1; 897 return 1;
898} 898}
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index ac0df3acdcda..b60699c271ac 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -173,7 +173,7 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
173 if (isdigit(state->name[strlen(state->name)-1])) 173 if (isdigit(state->name[strlen(state->name)-1]))
174 sprintf(state->name, "p"); 174 sprintf(state->name, "p");
175 175
176 state->limit = disk_max_parts(hd) + 1; 176 state->limit = disk_max_parts(hd);
177 i = res = err = 0; 177 i = res = err = 0;
178 while (!res && check_part[i]) { 178 while (!res && check_part[i]) {
179 memset(&state->parts, 0, sizeof(state->parts)); 179 memset(&state->parts, 0, sizeof(state->parts));
@@ -329,12 +329,12 @@ void delete_partition(struct gendisk *disk, int partno)
329{ 329{
330 struct hd_struct *part; 330 struct hd_struct *part;
331 331
332 part = disk->__part[partno-1]; 332 part = disk->__part[partno];
333 if (!part) 333 if (!part)
334 return; 334 return;
335 335
336 blk_free_devt(part_devt(part)); 336 blk_free_devt(part_devt(part));
337 rcu_assign_pointer(disk->__part[partno-1], NULL); 337 rcu_assign_pointer(disk->__part[partno], NULL);
338 kobject_put(part->holder_dir); 338 kobject_put(part->holder_dir);
339 device_del(part_to_dev(part)); 339 device_del(part_to_dev(part));
340 340
@@ -359,7 +359,7 @@ int add_partition(struct gendisk *disk, int partno,
359 const char *dname; 359 const char *dname;
360 int err; 360 int err;
361 361
362 if (disk->__part[partno - 1]) 362 if (disk->__part[partno])
363 return -EBUSY; 363 return -EBUSY;
364 364
365 p = kzalloc(sizeof(*p), GFP_KERNEL); 365 p = kzalloc(sizeof(*p), GFP_KERNEL);
@@ -413,7 +413,7 @@ int add_partition(struct gendisk *disk, int partno,
413 413
414 /* everything is up and running, commence */ 414 /* everything is up and running, commence */
415 INIT_RCU_HEAD(&p->rcu_head); 415 INIT_RCU_HEAD(&p->rcu_head);
416 rcu_assign_pointer(disk->__part[partno - 1], p); 416 rcu_assign_pointer(disk->__part[partno], p);
417 417
418 /* suppress uevent if the disk supresses it */ 418 /* suppress uevent if the disk supresses it */
419 if (!ddev->uevent_suppress) 419 if (!ddev->uevent_suppress)
@@ -467,7 +467,7 @@ void register_disk(struct gendisk *disk)
467 disk_sysfs_add_subdirs(disk); 467 disk_sysfs_add_subdirs(disk);
468 468
469 /* No minors to use for partitions */ 469 /* No minors to use for partitions */
470 if (!disk_max_parts(disk)) 470 if (!disk_partitionable(disk))
471 goto exit; 471 goto exit;
472 472
473 /* No such device (e.g., media were just removed) */ 473 /* No such device (e.g., media were just removed) */