Commit bc359d03 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

block: add a disk_uevent helper

Add a helper to call kobject_uevent for the disk and all partitions, and
unexport the disk_part_iter_* helpers that are now only used in the core
block code.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 0b6e522c
...@@ -203,7 +203,6 @@ void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk, ...@@ -203,7 +203,6 @@ void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk,
rcu_read_unlock(); rcu_read_unlock();
} }
EXPORT_SYMBOL_GPL(disk_part_iter_init);
/** /**
* disk_part_iter_next - proceed iterator to the next partition and return it * disk_part_iter_next - proceed iterator to the next partition and return it
...@@ -266,7 +265,6 @@ struct block_device *disk_part_iter_next(struct disk_part_iter *piter) ...@@ -266,7 +265,6 @@ struct block_device *disk_part_iter_next(struct disk_part_iter *piter)
return piter->part; return piter->part;
} }
EXPORT_SYMBOL_GPL(disk_part_iter_next);
/** /**
* disk_part_iter_exit - finish up partition iteration * disk_part_iter_exit - finish up partition iteration
...@@ -283,7 +281,6 @@ void disk_part_iter_exit(struct disk_part_iter *piter) ...@@ -283,7 +281,6 @@ void disk_part_iter_exit(struct disk_part_iter *piter)
bdput(piter->part); bdput(piter->part);
piter->part = NULL; piter->part = NULL;
} }
EXPORT_SYMBOL_GPL(disk_part_iter_exit);
/** /**
* disk_has_partitions * disk_has_partitions
...@@ -555,6 +552,18 @@ static char *bdevt_str(dev_t devt, char *buf) ...@@ -555,6 +552,18 @@ static char *bdevt_str(dev_t devt, char *buf)
return buf; return buf;
} }
void disk_uevent(struct gendisk *disk, enum kobject_action action)
{
struct disk_part_iter piter;
struct block_device *part;
disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
while ((part = disk_part_iter_next(&piter)))
kobject_uevent(bdev_kobj(part), action);
disk_part_iter_exit(&piter);
}
EXPORT_SYMBOL_GPL(disk_uevent);
static void disk_scan_partitions(struct gendisk *disk) static void disk_scan_partitions(struct gendisk *disk)
{ {
struct block_device *bdev; struct block_device *bdev;
...@@ -572,8 +581,6 @@ static void register_disk(struct device *parent, struct gendisk *disk, ...@@ -572,8 +581,6 @@ static void register_disk(struct device *parent, struct gendisk *disk,
const struct attribute_group **groups) const struct attribute_group **groups)
{ {
struct device *ddev = disk_to_dev(disk); struct device *ddev = disk_to_dev(disk);
struct disk_part_iter piter;
struct block_device *part;
int err; int err;
ddev->parent = parent; ddev->parent = parent;
...@@ -616,15 +623,9 @@ static void register_disk(struct device *parent, struct gendisk *disk, ...@@ -616,15 +623,9 @@ static void register_disk(struct device *parent, struct gendisk *disk,
disk_scan_partitions(disk); disk_scan_partitions(disk);
/* announce disk after possible partitions are created */ /* announce the disk and partitions after all partitions are created */
dev_set_uevent_suppress(ddev, 0); dev_set_uevent_suppress(ddev, 0);
kobject_uevent(&ddev->kobj, KOBJ_ADD); disk_uevent(disk, KOBJ_ADD);
/* announce possible partitions */
disk_part_iter_init(&piter, disk, 0);
while ((part = disk_part_iter_next(&piter)))
kobject_uevent(bdev_kobj(part), KOBJ_ADD);
disk_part_iter_exit(&piter);
if (disk->queue->backing_dev_info->dev) { if (disk->queue->backing_dev_info->dev) {
err = sysfs_create_link(&ddev->kobj, err = sysfs_create_link(&ddev->kobj,
......
...@@ -428,23 +428,15 @@ static int dasd_state_unfmt_to_basic(struct dasd_device *device) ...@@ -428,23 +428,15 @@ static int dasd_state_unfmt_to_basic(struct dasd_device *device)
static int static int
dasd_state_ready_to_online(struct dasd_device * device) dasd_state_ready_to_online(struct dasd_device * device)
{ {
struct gendisk *disk;
struct disk_part_iter piter;
struct block_device *part;
device->state = DASD_STATE_ONLINE; device->state = DASD_STATE_ONLINE;
if (device->block) { if (device->block) {
dasd_schedule_block_bh(device->block); dasd_schedule_block_bh(device->block);
if ((device->features & DASD_FEATURE_USERAW)) { if ((device->features & DASD_FEATURE_USERAW)) {
disk = device->block->gdp; kobject_uevent(&disk_to_dev(device->block->gdp)->kobj,
kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); KOBJ_CHANGE);
return 0; return 0;
} }
disk = device->block->bdev->bd_disk; disk_uevent(device->block->bdev->bd_disk, KOBJ_CHANGE);
disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
while ((part = disk_part_iter_next(&piter)))
kobject_uevent(bdev_kobj(part), KOBJ_CHANGE);
disk_part_iter_exit(&piter);
} }
return 0; return 0;
} }
...@@ -455,9 +447,6 @@ dasd_state_ready_to_online(struct dasd_device * device) ...@@ -455,9 +447,6 @@ dasd_state_ready_to_online(struct dasd_device * device)
static int dasd_state_online_to_ready(struct dasd_device *device) static int dasd_state_online_to_ready(struct dasd_device *device)
{ {
int rc; int rc;
struct gendisk *disk;
struct disk_part_iter piter;
struct block_device *part;
if (device->discipline->online_to_ready) { if (device->discipline->online_to_ready) {
rc = device->discipline->online_to_ready(device); rc = device->discipline->online_to_ready(device);
...@@ -466,13 +455,8 @@ static int dasd_state_online_to_ready(struct dasd_device *device) ...@@ -466,13 +455,8 @@ static int dasd_state_online_to_ready(struct dasd_device *device)
} }
device->state = DASD_STATE_READY; device->state = DASD_STATE_READY;
if (device->block && !(device->features & DASD_FEATURE_USERAW)) { if (device->block && !(device->features & DASD_FEATURE_USERAW))
disk = device->block->bdev->bd_disk; disk_uevent(device->block->bdev->bd_disk, KOBJ_CHANGE);
disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
while ((part = disk_part_iter_next(&piter)))
kobject_uevent(bdev_kobj(part), KOBJ_CHANGE);
disk_part_iter_exit(&piter);
}
return 0; return 0;
} }
......
...@@ -213,6 +213,8 @@ static inline dev_t disk_devt(struct gendisk *disk) ...@@ -213,6 +213,8 @@ static inline dev_t disk_devt(struct gendisk *disk)
return MKDEV(disk->major, disk->first_minor); return MKDEV(disk->major, disk->first_minor);
} }
void disk_uevent(struct gendisk *disk, enum kobject_action action);
/* /*
* Smarter partition iterator without context limits. * Smarter partition iterator without context limits.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment