Commit 00bcb4ac authored by NeilBrown's avatar NeilBrown

md: reduce dependence on sysfs.

We will want md devices to live as dm targets where sysfs is not
visible.  So allow md to not connect to sysfs.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent d0c6f625
This diff is collapsed.
...@@ -382,6 +382,18 @@ struct md_sysfs_entry { ...@@ -382,6 +382,18 @@ struct md_sysfs_entry {
}; };
extern struct attribute_group md_bitmap_group; extern struct attribute_group md_bitmap_group;
static inline struct sysfs_dirent *sysfs_get_dirent_safe(struct sysfs_dirent *sd, char *name)
{
if (sd)
return sysfs_get_dirent(sd, NULL, name);
return sd;
}
static inline void sysfs_notify_dirent_safe(struct sysfs_dirent *sd)
{
if (sd)
sysfs_notify_dirent(sd);
}
static inline char * mdname (mddev_t * mddev) static inline char * mdname (mddev_t * mddev)
{ {
return mddev->gendisk ? mddev->gendisk->disk_name : "mdX"; return mddev->gendisk ? mddev->gendisk->disk_name : "mdX";
......
...@@ -5158,7 +5158,8 @@ static int run(mddev_t *mddev) ...@@ -5158,7 +5158,8 @@ static int run(mddev_t *mddev)
/* Ok, everything is just fine now */ /* Ok, everything is just fine now */
if (mddev->to_remove == &raid5_attrs_group) if (mddev->to_remove == &raid5_attrs_group)
mddev->to_remove = NULL; mddev->to_remove = NULL;
else if (sysfs_create_group(&mddev->kobj, &raid5_attrs_group)) else if (mddev->kobj.sd &&
sysfs_create_group(&mddev->kobj, &raid5_attrs_group))
printk(KERN_WARNING printk(KERN_WARNING
"md/raid:%s: failed to create sysfs attributes.\n", "md/raid:%s: failed to create sysfs attributes.\n",
mdname(mddev)); mdname(mddev));
...@@ -5545,10 +5546,7 @@ static int raid5_start_reshape(mddev_t *mddev) ...@@ -5545,10 +5546,7 @@ static int raid5_start_reshape(mddev_t *mddev)
sprintf(nm, "rd%d", rdev->raid_disk); sprintf(nm, "rd%d", rdev->raid_disk);
if (sysfs_create_link(&mddev->kobj, if (sysfs_create_link(&mddev->kobj,
&rdev->kobj, nm)) &rdev->kobj, nm))
printk(KERN_WARNING /* Failure here is OK */;
"md/raid:%s: failed to create "
" link %s\n",
mdname(mddev), nm);
} else } else
break; break;
} }
......
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