diff options
author | Tejun Heo <tj@kernel.org> | 2008-08-25 06:56:11 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-10-09 02:56:08 -0400 |
commit | 4c46501d1659475dc6c89554af6ce7fe6ecf615c (patch) | |
tree | 03bfdf77e2d20c3190ba62532c783ab7f6a2640d | |
parent | b7db9956e57c8151b930d5e5fe5c766e6aad3ff7 (diff) |
block: move holder_dir from disk to part0
Move disk->holder_dir to part0->holder_dir. Kill now mostly
superflous bdev_get_holder().
While at it, kill superflous kobject_get/put() around holder_dir,
slave_dir and cmd_filter creation and collapse
disk_sysfs_add_subdirs() into register_disk(). These serve no purpose
but obfuscating the code.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r-- | block/cmd-filter.c | 9 | ||||
-rw-r--r-- | fs/block_dev.c | 10 | ||||
-rw-r--r-- | fs/partitions/check.c | 15 | ||||
-rw-r--r-- | include/linux/genhd.h | 1 |
4 files changed, 6 insertions, 29 deletions
diff --git a/block/cmd-filter.c b/block/cmd-filter.c index 79c14996ac11..e669aed4c6bc 100644 --- a/block/cmd-filter.c +++ b/block/cmd-filter.c | |||
@@ -211,14 +211,10 @@ int blk_register_filter(struct gendisk *disk) | |||
211 | { | 211 | { |
212 | int ret; | 212 | int ret; |
213 | struct blk_cmd_filter *filter = &disk->queue->cmd_filter; | 213 | struct blk_cmd_filter *filter = &disk->queue->cmd_filter; |
214 | struct kobject *parent = kobject_get(disk->holder_dir->parent); | ||
215 | 214 | ||
216 | if (!parent) | 215 | ret = kobject_init_and_add(&filter->kobj, &rcf_ktype, |
217 | return -ENODEV; | 216 | &disk_to_dev(disk)->kobj, |
218 | |||
219 | ret = kobject_init_and_add(&filter->kobj, &rcf_ktype, parent, | ||
220 | "%s", "cmd_filter"); | 217 | "%s", "cmd_filter"); |
221 | |||
222 | if (ret < 0) | 218 | if (ret < 0) |
223 | return ret; | 219 | return ret; |
224 | 220 | ||
@@ -231,7 +227,6 @@ void blk_unregister_filter(struct gendisk *disk) | |||
231 | struct blk_cmd_filter *filter = &disk->queue->cmd_filter; | 227 | struct blk_cmd_filter *filter = &disk->queue->cmd_filter; |
232 | 228 | ||
233 | kobject_put(&filter->kobj); | 229 | kobject_put(&filter->kobj); |
234 | kobject_put(disk->holder_dir->parent); | ||
235 | } | 230 | } |
236 | EXPORT_SYMBOL(blk_unregister_filter); | 231 | EXPORT_SYMBOL(blk_unregister_filter); |
237 | #endif | 232 | #endif |
diff --git a/fs/block_dev.c b/fs/block_dev.c index c982a9107979..57d572642854 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -548,14 +548,6 @@ static struct kobject *bdev_get_kobj(struct block_device *bdev) | |||
548 | return kobject_get(&disk_to_dev(bdev->bd_disk)->kobj); | 548 | return kobject_get(&disk_to_dev(bdev->bd_disk)->kobj); |
549 | } | 549 | } |
550 | 550 | ||
551 | static struct kobject *bdev_get_holder(struct block_device *bdev) | ||
552 | { | ||
553 | if (bdev->bd_contains != bdev) | ||
554 | return kobject_get(bdev->bd_part->holder_dir); | ||
555 | else | ||
556 | return kobject_get(bdev->bd_disk->holder_dir); | ||
557 | } | ||
558 | |||
559 | static int add_symlink(struct kobject *from, struct kobject *to) | 551 | static int add_symlink(struct kobject *from, struct kobject *to) |
560 | { | 552 | { |
561 | if (!from || !to) | 553 | if (!from || !to) |
@@ -608,7 +600,7 @@ static int bd_holder_grab_dirs(struct block_device *bdev, | |||
608 | if (!bo->sdev) | 600 | if (!bo->sdev) |
609 | goto fail_put_hdev; | 601 | goto fail_put_hdev; |
610 | 602 | ||
611 | bo->hdir = bdev_get_holder(bdev); | 603 | bo->hdir = kobject_get(bdev->bd_part->holder_dir); |
612 | if (!bo->hdir) | 604 | if (!bo->hdir) |
613 | goto fail_put_sdev; | 605 | goto fail_put_sdev; |
614 | 606 | ||
diff --git a/fs/partitions/check.c b/fs/partitions/check.c index ace6d03602c7..f0f604950ff4 100644 --- a/fs/partitions/check.c +++ b/fs/partitions/check.c | |||
@@ -305,16 +305,6 @@ struct device_type part_type = { | |||
305 | .release = part_release, | 305 | .release = part_release, |
306 | }; | 306 | }; |
307 | 307 | ||
308 | static inline void disk_sysfs_add_subdirs(struct gendisk *disk) | ||
309 | { | ||
310 | struct kobject *k; | ||
311 | |||
312 | k = kobject_get(&disk_to_dev(disk)->kobj); | ||
313 | disk->holder_dir = kobject_create_and_add("holders", k); | ||
314 | disk->slave_dir = kobject_create_and_add("slaves", k); | ||
315 | kobject_put(k); | ||
316 | } | ||
317 | |||
318 | static void delete_partition_rcu_cb(struct rcu_head *head) | 308 | static void delete_partition_rcu_cb(struct rcu_head *head) |
319 | { | 309 | { |
320 | struct hd_struct *part = container_of(head, struct hd_struct, rcu_head); | 310 | struct hd_struct *part = container_of(head, struct hd_struct, rcu_head); |
@@ -464,7 +454,8 @@ void register_disk(struct gendisk *disk) | |||
464 | return; | 454 | return; |
465 | } | 455 | } |
466 | #endif | 456 | #endif |
467 | disk_sysfs_add_subdirs(disk); | 457 | disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj); |
458 | disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); | ||
468 | 459 | ||
469 | /* No minors to use for partitions */ | 460 | /* No minors to use for partitions */ |
470 | if (!disk_partitionable(disk)) | 461 | if (!disk_partitionable(disk)) |
@@ -592,7 +583,7 @@ void del_gendisk(struct gendisk *disk) | |||
592 | disk_stat_set_all(disk, 0); | 583 | disk_stat_set_all(disk, 0); |
593 | disk->stamp = 0; | 584 | disk->stamp = 0; |
594 | 585 | ||
595 | kobject_put(disk->holder_dir); | 586 | kobject_put(disk->part0.holder_dir); |
596 | kobject_put(disk->slave_dir); | 587 | kobject_put(disk->slave_dir); |
597 | disk->driverfs_dev = NULL; | 588 | disk->driverfs_dev = NULL; |
598 | #ifndef CONFIG_SYSFS_DEPRECATED | 589 | #ifndef CONFIG_SYSFS_DEPRECATED |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index 4411bdd671dd..2c0e1b597ab4 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -141,7 +141,6 @@ struct gendisk { | |||
141 | 141 | ||
142 | int flags; | 142 | int flags; |
143 | struct device *driverfs_dev; // FIXME: remove | 143 | struct device *driverfs_dev; // FIXME: remove |
144 | struct kobject *holder_dir; | ||
145 | struct kobject *slave_dir; | 144 | struct kobject *slave_dir; |
146 | 145 | ||
147 | struct timer_rand_state *random; | 146 | struct timer_rand_state *random; |