aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-06-01 05:37:23 -0400
committerNeilBrown <neilb@suse.de>2010-07-20 23:27:53 -0400
commit00bcb4ac7ee7e557a491b614219142cea0ef16f4 (patch)
tree992cfa1d0e653aa3de8f0865c5e1a5a0fee4f935 /drivers
parentd0c6f6258478e1dba532bf7c28e2cd6e1047d3a4 (diff)
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: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c101
-rw-r--r--drivers/md/md.h12
-rw-r--r--drivers/md/raid5.c8
3 files changed, 62 insertions, 59 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index cb20d0b0555a..9007651ce175 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -541,14 +541,16 @@ static void mddev_unlock(mddev_t * mddev)
541 mutex_lock(&mddev->open_mutex); 541 mutex_lock(&mddev->open_mutex);
542 mutex_unlock(&mddev->reconfig_mutex); 542 mutex_unlock(&mddev->reconfig_mutex);
543 543
544 if (to_remove != &md_redundancy_group) 544 if (mddev->kobj.sd) {
545 sysfs_remove_group(&mddev->kobj, to_remove); 545 if (to_remove != &md_redundancy_group)
546 if (mddev->pers == NULL || 546 sysfs_remove_group(&mddev->kobj, to_remove);
547 mddev->pers->sync_request == NULL) { 547 if (mddev->pers == NULL ||
548 sysfs_remove_group(&mddev->kobj, &md_redundancy_group); 548 mddev->pers->sync_request == NULL) {
549 if (mddev->sysfs_action) 549 sysfs_remove_group(&mddev->kobj, &md_redundancy_group);
550 sysfs_put(mddev->sysfs_action); 550 if (mddev->sysfs_action)
551 mddev->sysfs_action = NULL; 551 sysfs_put(mddev->sysfs_action);
552 mddev->sysfs_action = NULL;
553 }
552 } 554 }
553 mutex_unlock(&mddev->open_mutex); 555 mutex_unlock(&mddev->open_mutex);
554 } else 556 } else
@@ -1811,11 +1813,9 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1811 goto fail; 1813 goto fail;
1812 1814
1813 ko = &part_to_dev(rdev->bdev->bd_part)->kobj; 1815 ko = &part_to_dev(rdev->bdev->bd_part)->kobj;
1814 if ((err = sysfs_create_link(&rdev->kobj, ko, "block"))) { 1816 if (sysfs_create_link(&rdev->kobj, ko, "block"))
1815 kobject_del(&rdev->kobj); 1817 /* failure here is OK */;
1816 goto fail; 1818 rdev->sysfs_state = sysfs_get_dirent_safe(rdev->kobj.sd, "state");
1817 }
1818 rdev->sysfs_state = sysfs_get_dirent(rdev->kobj.sd, NULL, "state");
1819 1819
1820 list_add_rcu(&rdev->same_set, &mddev->disks); 1820 list_add_rcu(&rdev->same_set, &mddev->disks);
1821 bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk); 1821 bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk);
@@ -2334,8 +2334,8 @@ state_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2334 set_bit(In_sync, &rdev->flags); 2334 set_bit(In_sync, &rdev->flags);
2335 err = 0; 2335 err = 0;
2336 } 2336 }
2337 if (!err && rdev->sysfs_state) 2337 if (!err)
2338 sysfs_notify_dirent(rdev->sysfs_state); 2338 sysfs_notify_dirent_safe(rdev->sysfs_state);
2339 return err ? err : len; 2339 return err ? err : len;
2340} 2340}
2341static struct rdev_sysfs_entry rdev_state = 2341static struct rdev_sysfs_entry rdev_state =
@@ -2430,14 +2430,10 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2430 rdev->raid_disk = -1; 2430 rdev->raid_disk = -1;
2431 return err; 2431 return err;
2432 } else 2432 } else
2433 sysfs_notify_dirent(rdev->sysfs_state); 2433 sysfs_notify_dirent_safe(rdev->sysfs_state);
2434 sprintf(nm, "rd%d", rdev->raid_disk); 2434 sprintf(nm, "rd%d", rdev->raid_disk);
2435 if (sysfs_create_link(&rdev->mddev->kobj, &rdev->kobj, nm)) 2435 if (sysfs_create_link(&rdev->mddev->kobj, &rdev->kobj, nm))
2436 printk(KERN_WARNING 2436 /* failure here is OK */;
2437 "md: cannot register "
2438 "%s for %s\n",
2439 nm, mdname(rdev->mddev));
2440
2441 /* don't wakeup anyone, leave that to userspace. */ 2437 /* don't wakeup anyone, leave that to userspace. */
2442 } else { 2438 } else {
2443 if (slot >= rdev->mddev->raid_disks) 2439 if (slot >= rdev->mddev->raid_disks)
@@ -2447,7 +2443,7 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2447 clear_bit(Faulty, &rdev->flags); 2443 clear_bit(Faulty, &rdev->flags);
2448 clear_bit(WriteMostly, &rdev->flags); 2444 clear_bit(WriteMostly, &rdev->flags);
2449 set_bit(In_sync, &rdev->flags); 2445 set_bit(In_sync, &rdev->flags);
2450 sysfs_notify_dirent(rdev->sysfs_state); 2446 sysfs_notify_dirent_safe(rdev->sysfs_state);
2451 } 2447 }
2452 return len; 2448 return len;
2453} 2449}
@@ -3437,7 +3433,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
3437 if (err) 3433 if (err)
3438 return err; 3434 return err;
3439 else { 3435 else {
3440 sysfs_notify_dirent(mddev->sysfs_state); 3436 sysfs_notify_dirent_safe(mddev->sysfs_state);
3441 return len; 3437 return len;
3442 } 3438 }
3443} 3439}
@@ -3735,7 +3731,7 @@ action_store(mddev_t *mddev, const char *page, size_t len)
3735 } 3731 }
3736 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 3732 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
3737 md_wakeup_thread(mddev->thread); 3733 md_wakeup_thread(mddev->thread);
3738 sysfs_notify_dirent(mddev->sysfs_action); 3734 sysfs_notify_dirent_safe(mddev->sysfs_action);
3739 return len; 3735 return len;
3740} 3736}
3741 3737
@@ -4281,13 +4277,14 @@ static int md_alloc(dev_t dev, char *name)
4281 disk->disk_name); 4277 disk->disk_name);
4282 error = 0; 4278 error = 0;
4283 } 4279 }
4284 if (sysfs_create_group(&mddev->kobj, &md_bitmap_group)) 4280 if (mddev->kobj.sd &&
4281 sysfs_create_group(&mddev->kobj, &md_bitmap_group))
4285 printk(KERN_DEBUG "pointless warning\n"); 4282 printk(KERN_DEBUG "pointless warning\n");
4286 abort: 4283 abort:
4287 mutex_unlock(&disks_mutex); 4284 mutex_unlock(&disks_mutex);
4288 if (!error) { 4285 if (!error && mddev->kobj.sd) {
4289 kobject_uevent(&mddev->kobj, KOBJ_ADD); 4286 kobject_uevent(&mddev->kobj, KOBJ_ADD);
4290 mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, NULL, "array_state"); 4287 mddev->sysfs_state = sysfs_get_dirent_safe(mddev->kobj.sd, "array_state");
4291 } 4288 }
4292 mddev_put(mddev); 4289 mddev_put(mddev);
4293 return error; 4290 return error;
@@ -4325,7 +4322,7 @@ static void md_safemode_timeout(unsigned long data)
4325 if (!atomic_read(&mddev->writes_pending)) { 4322 if (!atomic_read(&mddev->writes_pending)) {
4326 mddev->safemode = 1; 4323 mddev->safemode = 1;
4327 if (mddev->external) 4324 if (mddev->external)
4328 sysfs_notify_dirent(mddev->sysfs_state); 4325 sysfs_notify_dirent_safe(mddev->sysfs_state);
4329 } 4326 }
4330 md_wakeup_thread(mddev->thread); 4327 md_wakeup_thread(mddev->thread);
4331} 4328}
@@ -4397,7 +4394,7 @@ static int md_run(mddev_t *mddev)
4397 return -EINVAL; 4394 return -EINVAL;
4398 } 4395 }
4399 } 4396 }
4400 sysfs_notify_dirent(rdev->sysfs_state); 4397 sysfs_notify_dirent_safe(rdev->sysfs_state);
4401 } 4398 }
4402 4399
4403 spin_lock(&pers_lock); 4400 spin_lock(&pers_lock);
@@ -4496,11 +4493,12 @@ static int md_run(mddev_t *mddev)
4496 return err; 4493 return err;
4497 } 4494 }
4498 if (mddev->pers->sync_request) { 4495 if (mddev->pers->sync_request) {
4499 if (sysfs_create_group(&mddev->kobj, &md_redundancy_group)) 4496 if (mddev->kobj.sd &&
4497 sysfs_create_group(&mddev->kobj, &md_redundancy_group))
4500 printk(KERN_WARNING 4498 printk(KERN_WARNING
4501 "md: cannot register extra attributes for %s\n", 4499 "md: cannot register extra attributes for %s\n",
4502 mdname(mddev)); 4500 mdname(mddev));
4503 mddev->sysfs_action = sysfs_get_dirent(mddev->kobj.sd, NULL, "sync_action"); 4501 mddev->sysfs_action = sysfs_get_dirent_safe(mddev->kobj.sd, "sync_action");
4504 } else if (mddev->ro == 2) /* auto-readonly not meaningful */ 4502 } else if (mddev->ro == 2) /* auto-readonly not meaningful */
4505 mddev->ro = 0; 4503 mddev->ro = 0;
4506 4504
@@ -4518,8 +4516,7 @@ static int md_run(mddev_t *mddev)
4518 char nm[20]; 4516 char nm[20];
4519 sprintf(nm, "rd%d", rdev->raid_disk); 4517 sprintf(nm, "rd%d", rdev->raid_disk);
4520 if (sysfs_create_link(&mddev->kobj, &rdev->kobj, nm)) 4518 if (sysfs_create_link(&mddev->kobj, &rdev->kobj, nm))
4521 printk("md: cannot register %s for %s\n", 4519 /* failure here is OK */;
4522 nm, mdname(mddev));
4523 } 4520 }
4524 4521
4525 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 4522 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
@@ -4531,9 +4528,8 @@ static int md_run(mddev_t *mddev)
4531 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ 4528 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
4532 4529
4533 md_new_event(mddev); 4530 md_new_event(mddev);
4534 sysfs_notify_dirent(mddev->sysfs_state); 4531 sysfs_notify_dirent_safe(mddev->sysfs_state);
4535 if (mddev->sysfs_action) 4532 sysfs_notify_dirent_safe(mddev->sysfs_action);
4536 sysfs_notify_dirent(mddev->sysfs_action);
4537 sysfs_notify(&mddev->kobj, NULL, "degraded"); 4533 sysfs_notify(&mddev->kobj, NULL, "degraded");
4538 return 0; 4534 return 0;
4539} 4535}
@@ -4573,7 +4569,7 @@ static int restart_array(mddev_t *mddev)
4573 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 4569 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
4574 md_wakeup_thread(mddev->thread); 4570 md_wakeup_thread(mddev->thread);
4575 md_wakeup_thread(mddev->sync_thread); 4571 md_wakeup_thread(mddev->sync_thread);
4576 sysfs_notify_dirent(mddev->sysfs_state); 4572 sysfs_notify_dirent_safe(mddev->sysfs_state);
4577 return 0; 4573 return 0;
4578} 4574}
4579 4575
@@ -4697,7 +4693,7 @@ static int md_set_readonly(mddev_t *mddev, int is_open)
4697 mddev->ro = 1; 4693 mddev->ro = 1;
4698 set_disk_ro(mddev->gendisk, 1); 4694 set_disk_ro(mddev->gendisk, 1);
4699 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 4695 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
4700 sysfs_notify_dirent(mddev->sysfs_state); 4696 sysfs_notify_dirent_safe(mddev->sysfs_state);
4701 err = 0; 4697 err = 0;
4702 } 4698 }
4703out: 4699out:
@@ -4730,7 +4726,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4730 mddev->queue->backing_dev_info.congested_fn = NULL; 4726 mddev->queue->backing_dev_info.congested_fn = NULL;
4731 4727
4732 /* tell userspace to handle 'inactive' */ 4728 /* tell userspace to handle 'inactive' */
4733 sysfs_notify_dirent(mddev->sysfs_state); 4729 sysfs_notify_dirent_safe(mddev->sysfs_state);
4734 4730
4735 list_for_each_entry(rdev, &mddev->disks, same_set) 4731 list_for_each_entry(rdev, &mddev->disks, same_set)
4736 if (rdev->raid_disk >= 0) { 4732 if (rdev->raid_disk >= 0) {
@@ -4776,7 +4772,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4776 err = 0; 4772 err = 0;
4777 blk_integrity_unregister(disk); 4773 blk_integrity_unregister(disk);
4778 md_new_event(mddev); 4774 md_new_event(mddev);
4779 sysfs_notify_dirent(mddev->sysfs_state); 4775 sysfs_notify_dirent_safe(mddev->sysfs_state);
4780 return err; 4776 return err;
4781} 4777}
4782 4778
@@ -5138,7 +5134,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
5138 if (err) 5134 if (err)
5139 export_rdev(rdev); 5135 export_rdev(rdev);
5140 else 5136 else
5141 sysfs_notify_dirent(rdev->sysfs_state); 5137 sysfs_notify_dirent_safe(rdev->sysfs_state);
5142 5138
5143 md_update_sb(mddev, 1); 5139 md_update_sb(mddev, 1);
5144 if (mddev->degraded) 5140 if (mddev->degraded)
@@ -5813,7 +5809,7 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
5813 if (_IOC_TYPE(cmd) == MD_MAJOR && mddev->ro && mddev->pers) { 5809 if (_IOC_TYPE(cmd) == MD_MAJOR && mddev->ro && mddev->pers) {
5814 if (mddev->ro == 2) { 5810 if (mddev->ro == 2) {
5815 mddev->ro = 0; 5811 mddev->ro = 0;
5816 sysfs_notify_dirent(mddev->sysfs_state); 5812 sysfs_notify_dirent_safe(mddev->sysfs_state);
5817 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 5813 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
5818 md_wakeup_thread(mddev->thread); 5814 md_wakeup_thread(mddev->thread);
5819 } else { 5815 } else {
@@ -6059,7 +6055,7 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev)
6059 mddev->pers->error_handler(mddev,rdev); 6055 mddev->pers->error_handler(mddev,rdev);
6060 if (mddev->degraded) 6056 if (mddev->degraded)
6061 set_bit(MD_RECOVERY_RECOVER, &mddev->recovery); 6057 set_bit(MD_RECOVERY_RECOVER, &mddev->recovery);
6062 sysfs_notify_dirent(rdev->sysfs_state); 6058 sysfs_notify_dirent_safe(rdev->sysfs_state);
6063 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 6059 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
6064 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 6060 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
6065 md_wakeup_thread(mddev->thread); 6061 md_wakeup_thread(mddev->thread);
@@ -6520,7 +6516,7 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
6520 spin_unlock_irq(&mddev->write_lock); 6516 spin_unlock_irq(&mddev->write_lock);
6521 } 6517 }
6522 if (did_change) 6518 if (did_change)
6523 sysfs_notify_dirent(mddev->sysfs_state); 6519 sysfs_notify_dirent_safe(mddev->sysfs_state);
6524 wait_event(mddev->sb_wait, 6520 wait_event(mddev->sb_wait,
6525 !test_bit(MD_CHANGE_CLEAN, &mddev->flags) && 6521 !test_bit(MD_CHANGE_CLEAN, &mddev->flags) &&
6526 !test_bit(MD_CHANGE_PENDING, &mddev->flags)); 6522 !test_bit(MD_CHANGE_PENDING, &mddev->flags));
@@ -6563,7 +6559,7 @@ int md_allow_write(mddev_t *mddev)
6563 mddev->safemode = 1; 6559 mddev->safemode = 1;
6564 spin_unlock_irq(&mddev->write_lock); 6560 spin_unlock_irq(&mddev->write_lock);
6565 md_update_sb(mddev, 0); 6561 md_update_sb(mddev, 0);
6566 sysfs_notify_dirent(mddev->sysfs_state); 6562 sysfs_notify_dirent_safe(mddev->sysfs_state);
6567 } else 6563 } else
6568 spin_unlock_irq(&mddev->write_lock); 6564 spin_unlock_irq(&mddev->write_lock);
6569 6565
@@ -6950,10 +6946,7 @@ static int remove_and_add_spares(mddev_t *mddev)
6950 sprintf(nm, "rd%d", rdev->raid_disk); 6946 sprintf(nm, "rd%d", rdev->raid_disk);
6951 if (sysfs_create_link(&mddev->kobj, 6947 if (sysfs_create_link(&mddev->kobj,
6952 &rdev->kobj, nm)) 6948 &rdev->kobj, nm))
6953 printk(KERN_WARNING 6949 /* failure here is OK */;
6954 "md: cannot register "
6955 "%s for %s\n",
6956 nm, mdname(mddev));
6957 spares++; 6950 spares++;
6958 md_new_event(mddev); 6951 md_new_event(mddev);
6959 set_bit(MD_CHANGE_DEVS, &mddev->flags); 6952 set_bit(MD_CHANGE_DEVS, &mddev->flags);
@@ -7046,7 +7039,7 @@ void md_check_recovery(mddev_t *mddev)
7046 mddev->safemode = 0; 7039 mddev->safemode = 0;
7047 spin_unlock_irq(&mddev->write_lock); 7040 spin_unlock_irq(&mddev->write_lock);
7048 if (did_change) 7041 if (did_change)
7049 sysfs_notify_dirent(mddev->sysfs_state); 7042 sysfs_notify_dirent_safe(mddev->sysfs_state);
7050 } 7043 }
7051 7044
7052 if (mddev->flags) 7045 if (mddev->flags)
@@ -7085,7 +7078,7 @@ void md_check_recovery(mddev_t *mddev)
7085 mddev->recovery = 0; 7078 mddev->recovery = 0;
7086 /* flag recovery needed just to double check */ 7079 /* flag recovery needed just to double check */
7087 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 7080 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
7088 sysfs_notify_dirent(mddev->sysfs_action); 7081 sysfs_notify_dirent_safe(mddev->sysfs_action);
7089 md_new_event(mddev); 7082 md_new_event(mddev);
7090 goto unlock; 7083 goto unlock;
7091 } 7084 }
@@ -7147,7 +7140,7 @@ void md_check_recovery(mddev_t *mddev)
7147 mddev->recovery = 0; 7140 mddev->recovery = 0;
7148 } else 7141 } else
7149 md_wakeup_thread(mddev->sync_thread); 7142 md_wakeup_thread(mddev->sync_thread);
7150 sysfs_notify_dirent(mddev->sysfs_action); 7143 sysfs_notify_dirent_safe(mddev->sysfs_action);
7151 md_new_event(mddev); 7144 md_new_event(mddev);
7152 } 7145 }
7153 unlock: 7146 unlock:
@@ -7156,7 +7149,7 @@ void md_check_recovery(mddev_t *mddev)
7156 if (test_and_clear_bit(MD_RECOVERY_RECOVER, 7149 if (test_and_clear_bit(MD_RECOVERY_RECOVER,
7157 &mddev->recovery)) 7150 &mddev->recovery))
7158 if (mddev->sysfs_action) 7151 if (mddev->sysfs_action)
7159 sysfs_notify_dirent(mddev->sysfs_action); 7152 sysfs_notify_dirent_safe(mddev->sysfs_action);
7160 } 7153 }
7161 mddev_unlock(mddev); 7154 mddev_unlock(mddev);
7162 } 7155 }
@@ -7164,7 +7157,7 @@ void md_check_recovery(mddev_t *mddev)
7164 7157
7165void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev) 7158void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev)
7166{ 7159{
7167 sysfs_notify_dirent(rdev->sysfs_state); 7160 sysfs_notify_dirent_safe(rdev->sysfs_state);
7168 wait_event_timeout(rdev->blocked_wait, 7161 wait_event_timeout(rdev->blocked_wait,
7169 !test_bit(Blocked, &rdev->flags), 7162 !test_bit(Blocked, &rdev->flags),
7170 msecs_to_jiffies(5000)); 7163 msecs_to_jiffies(5000));
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 10597bfec000..1e6405918eec 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -382,6 +382,18 @@ struct md_sysfs_entry {
382}; 382};
383extern struct attribute_group md_bitmap_group; 383extern struct attribute_group md_bitmap_group;
384 384
385static inline struct sysfs_dirent *sysfs_get_dirent_safe(struct sysfs_dirent *sd, char *name)
386{
387 if (sd)
388 return sysfs_get_dirent(sd, NULL, name);
389 return sd;
390}
391static inline void sysfs_notify_dirent_safe(struct sysfs_dirent *sd)
392{
393 if (sd)
394 sysfs_notify_dirent(sd);
395}
396
385static inline char * mdname (mddev_t * mddev) 397static inline char * mdname (mddev_t * mddev)
386{ 398{
387 return mddev->gendisk ? mddev->gendisk->disk_name : "mdX"; 399 return mddev->gendisk ? mddev->gendisk->disk_name : "mdX";
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 96c690279fc6..6a7a30113161 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5158,7 +5158,8 @@ static int run(mddev_t *mddev)
5158 /* Ok, everything is just fine now */ 5158 /* Ok, everything is just fine now */
5159 if (mddev->to_remove == &raid5_attrs_group) 5159 if (mddev->to_remove == &raid5_attrs_group)
5160 mddev->to_remove = NULL; 5160 mddev->to_remove = NULL;
5161 else if (sysfs_create_group(&mddev->kobj, &raid5_attrs_group)) 5161 else if (mddev->kobj.sd &&
5162 sysfs_create_group(&mddev->kobj, &raid5_attrs_group))
5162 printk(KERN_WARNING 5163 printk(KERN_WARNING
5163 "md/raid:%s: failed to create sysfs attributes.\n", 5164 "md/raid:%s: failed to create sysfs attributes.\n",
5164 mdname(mddev)); 5165 mdname(mddev));
@@ -5545,10 +5546,7 @@ static int raid5_start_reshape(mddev_t *mddev)
5545 sprintf(nm, "rd%d", rdev->raid_disk); 5546 sprintf(nm, "rd%d", rdev->raid_disk);
5546 if (sysfs_create_link(&mddev->kobj, 5547 if (sysfs_create_link(&mddev->kobj,
5547 &rdev->kobj, nm)) 5548 &rdev->kobj, nm))
5548 printk(KERN_WARNING 5549 /* Failure here is OK */;
5549 "md/raid:%s: failed to create "
5550 " link %s\n",
5551 mdname(mddev), nm);
5552 } else 5550 } else
5553 break; 5551 break;
5554 } 5552 }