aboutsummaryrefslogtreecommitdiffstats
path: root/fs/partitions
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2006-03-24 14:45:35 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-04-14 14:41:24 -0400
commitd4d7e5dffc4844ef51fe11f497bd774c04413a00 (patch)
treee65b52809b9178c627f0d73c6b4bdf1fb3e03889 /fs/partitions
parent0f836ca4c122f4ef096110d652a6326fe34e6961 (diff)
[PATCH] BLOCK: delay all uevents until partition table is scanned
[BLOCK] delay all uevents until partition table is scanned Here we delay the annoucement of all block device events until the disk's partition table is scanned and all partition devices are already created and sysfs is populated. We have a bunch of old bugs for removable storage handling where we probe successfully for a filesystem on the raw disk, but at the same time the kernel recognizes a partition table and creates partition devices. Currently there is no sane way to tell if partitions will show up or not at the time the disk device is announced to userspace. With the delayed events we can simply skip any probe for a filesystem on the raw disk when we find already present partitions. Signed-off-by: Kay Sievers <kay.sievers@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/partitions')
-rw-r--r--fs/partitions/check.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index af0cb4b9e784..f3b6af071722 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -331,7 +331,9 @@ void delete_partition(struct gendisk *disk, int part)
331 devfs_remove("%s/part%d", disk->devfs_name, part); 331 devfs_remove("%s/part%d", disk->devfs_name, part);
332 if (p->holder_dir) 332 if (p->holder_dir)
333 kobject_unregister(p->holder_dir); 333 kobject_unregister(p->holder_dir);
334 kobject_unregister(&p->kobj); 334 kobject_uevent(&p->kobj, KOBJ_REMOVE);
335 kobject_del(&p->kobj);
336 kobject_put(&p->kobj);
335} 337}
336 338
337void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len) 339void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
@@ -357,7 +359,10 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len)
357 snprintf(p->kobj.name,KOBJ_NAME_LEN,"%s%d",disk->kobj.name,part); 359 snprintf(p->kobj.name,KOBJ_NAME_LEN,"%s%d",disk->kobj.name,part);
358 p->kobj.parent = &disk->kobj; 360 p->kobj.parent = &disk->kobj;
359 p->kobj.ktype = &ktype_part; 361 p->kobj.ktype = &ktype_part;
360 kobject_register(&p->kobj); 362 kobject_init(&p->kobj);
363 kobject_add(&p->kobj);
364 if (!disk->part_uevent_suppress)
365 kobject_uevent(&p->kobj, KOBJ_ADD);
361 partition_sysfs_add_subdir(p); 366 partition_sysfs_add_subdir(p);
362 disk->part[part-1] = p; 367 disk->part[part-1] = p;
363} 368}
@@ -395,6 +400,8 @@ void register_disk(struct gendisk *disk)
395{ 400{
396 struct block_device *bdev; 401 struct block_device *bdev;
397 char *s; 402 char *s;
403 int i;
404 struct hd_struct *p;
398 int err; 405 int err;
399 406
400 strlcpy(disk->kobj.name,disk->disk_name,KOBJ_NAME_LEN); 407 strlcpy(disk->kobj.name,disk->disk_name,KOBJ_NAME_LEN);
@@ -406,13 +413,12 @@ void register_disk(struct gendisk *disk)
406 return; 413 return;
407 disk_sysfs_symlinks(disk); 414 disk_sysfs_symlinks(disk);
408 disk_sysfs_add_subdirs(disk); 415 disk_sysfs_add_subdirs(disk);
409 kobject_uevent(&disk->kobj, KOBJ_ADD);
410 416
411 /* No minors to use for partitions */ 417 /* No minors to use for partitions */
412 if (disk->minors == 1) { 418 if (disk->minors == 1) {
413 if (disk->devfs_name[0] != '\0') 419 if (disk->devfs_name[0] != '\0')
414 devfs_add_disk(disk); 420 devfs_add_disk(disk);
415 return; 421 goto exit;
416 } 422 }
417 423
418 /* always add handle for the whole disk */ 424 /* always add handle for the whole disk */
@@ -420,16 +426,32 @@ void register_disk(struct gendisk *disk)
420 426
421 /* No such device (e.g., media were just removed) */ 427 /* No such device (e.g., media were just removed) */
422 if (!get_capacity(disk)) 428 if (!get_capacity(disk))
423 return; 429 goto exit;
424 430
425 bdev = bdget_disk(disk, 0); 431 bdev = bdget_disk(disk, 0);
426 if (!bdev) 432 if (!bdev)
427 return; 433 goto exit;
428 434
435 /* scan partition table, but suppress uevents */
429 bdev->bd_invalidated = 1; 436 bdev->bd_invalidated = 1;
430 if (blkdev_get(bdev, FMODE_READ, 0) < 0) 437 disk->part_uevent_suppress = 1;
431 return; 438 err = blkdev_get(bdev, FMODE_READ, 0);
439 disk->part_uevent_suppress = 0;
440 if (err < 0)
441 goto exit;
432 blkdev_put(bdev); 442 blkdev_put(bdev);
443
444exit:
445 /* announce disk after possible partitions are already created */
446 kobject_uevent(&disk->kobj, KOBJ_ADD);
447
448 /* announce possible partitions */
449 for (i = 1; i < disk->minors; i++) {
450 p = disk->part[i-1];
451 if (!p || !p->nr_sects)
452 continue;
453 kobject_uevent(&p->kobj, KOBJ_ADD);
454 }
433} 455}
434 456
435int rescan_partitions(struct gendisk *disk, struct block_device *bdev) 457int rescan_partitions(struct gendisk *disk, struct block_device *bdev)