Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f637b9f9 authored by NeilBrown's avatar NeilBrown Committed by Linus Torvalds
Browse files

[PATCH] md: make sure /block link in /sys/.../md/ goes to correct devices



If a block_device is a partition, then it's kobject is
  bdev->bd_part->kobj
otherwise (if it is a full device), the kobject is
  bdev->bd_disk->kobj

As md wants back-links to the correct object (whether partition or not), we
need to respect this difference...  (Thus current code shows a link to the
whole device, whether we are using a partition or not, which is wrong).

Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f91de92e
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1182,6 +1182,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
{
	mdk_rdev_t *same_pdev;
	char b[BDEVNAME_SIZE], b2[BDEVNAME_SIZE];
	struct kobject *ko;

	if (rdev->mddev) {
		MD_BUG();
@@ -1221,7 +1222,11 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
	rdev->kobj.parent = &mddev->kobj;
	kobject_add(&rdev->kobj);

	sysfs_create_link(&rdev->kobj, &rdev->bdev->bd_disk->kobj, "block");
	if (rdev->bdev->bd_part)
		ko = &rdev->bdev->bd_part->kobj;
	else
		ko = &rdev->bdev->bd_disk->kobj;
	sysfs_create_link(&rdev->kobj, ko, "block");
	return 0;
}