aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-09-03 09:06:42 +0200
committerJens Axboe <jens.axboe@oracle.com>2008-10-09 08:56:07 +0200
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 a02df22f37c..c982a910797 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -892,7 +892,7 @@ int check_disk_change(struct block_device *bdev)
if (bdops->revalidate_disk)
bdops->revalidate_disk(bdev->bd_disk);
- if (disk_max_parts(bdev->bd_disk))
+ if (disk_partitionable(bdev->bd_disk))
bdev->bd_invalidated = 1;
return 1;
}
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index ac0df3acdcd..b60699c271a 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -173,7 +173,7 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
if (isdigit(state->name[strlen(state->name)-1]))
sprintf(state->name, "p");
- state->limit = disk_max_parts(hd) + 1;
+ state->limit = disk_max_parts(hd);
i = res = err = 0;
while (!res && check_part[i]) {
memset(&state->parts, 0, sizeof(state->parts));
@@ -329,12 +329,12 @@ void delete_partition(struct gendisk *disk, int partno)
{
struct hd_struct *part;
- part = disk->__part[partno-1];
+ part = disk->__part[partno];
if (!part)
return;
blk_free_devt(part_devt(part));
- rcu_assign_pointer(disk->__part[partno-1], NULL);
+ rcu_assign_pointer(disk->__part[partno], NULL);
kobject_put(part->holder_dir);
device_del(part_to_dev(part));
@@ -359,7 +359,7 @@ int add_partition(struct gendisk *disk, int partno,
const char *dname;
int err;
- if (disk->__part[partno - 1])
+ if (disk->__part[partno])
return -EBUSY;
p = kzalloc(sizeof(*p), GFP_KERNEL);
@@ -413,7 +413,7 @@ int add_partition(struct gendisk *disk, int partno,
/* everything is up and running, commence */
INIT_RCU_HEAD(&p->rcu_head);
- rcu_assign_pointer(disk->__part[partno - 1], p);
+ rcu_assign_pointer(disk->__part[partno], p);
/* suppress uevent if the disk supresses it */
if (!ddev->uevent_suppress)
@@ -467,7 +467,7 @@ void register_disk(struct gendisk *disk)
disk_sysfs_add_subdirs(disk);
/* No minors to use for partitions */
- if (!disk_max_parts(disk))
+ if (!disk_partitionable(disk))
goto exit;
/* No such device (e.g., media were just removed) */