Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197471
b: refs/heads/master
c: a64c876
h: refs/heads/master
i:
  197469: 1a24dfb
  197467: bab4989
  197463: bfad73b
  197455: 949a1a9
  197439: ce75c91
v: v3
  • Loading branch information
NeilBrown committed May 17, 2010
1 parent 3ea0a8b commit 76eedc1
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b6eb127d274385d81ce8dd45c98190f097bce1b4
refs/heads/master: a64c876fd357906a1f7193723866562ad290654c
43 changes: 32 additions & 11 deletions trunk/drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,9 @@ static inline int mddev_trylock(mddev_t * mddev)

static struct attribute_group md_redundancy_group;

static inline void mddev_unlock(mddev_t * mddev)
static void mddev_unlock(mddev_t * mddev)
{
if (mddev->pers == NULL && mddev->private) {
if (mddev->to_remove) {
/* These cannot be removed under reconfig_mutex as
* an access to the files will try to take reconfig_mutex
* while holding the file unremovable, which leads to
Expand All @@ -520,16 +520,20 @@ static inline void mddev_unlock(mddev_t * mddev)
* it while holding reconfig_mutex, and md_run can
* use it to wait for the remove to complete.
*/
struct attribute_group *to_remove = mddev->to_remove;
mddev->to_remove = NULL;
mutex_lock(&mddev->open_mutex);
mutex_unlock(&mddev->reconfig_mutex);

sysfs_remove_group(&mddev->kobj, &md_redundancy_group);
if (mddev->private != (void*)1)
sysfs_remove_group(&mddev->kobj, mddev->private);
if (mddev->sysfs_action)
sysfs_put(mddev->sysfs_action);
mddev->sysfs_action = NULL;
mddev->private = NULL;
if (to_remove != &md_redundancy_group)
sysfs_remove_group(&mddev->kobj, to_remove);
if (mddev->pers == NULL ||
mddev->pers->sync_request == NULL) {
sysfs_remove_group(&mddev->kobj, &md_redundancy_group);
if (mddev->sysfs_action)
sysfs_put(mddev->sysfs_action);
mddev->sysfs_action = NULL;
}
mutex_unlock(&mddev->open_mutex);
} else
mutex_unlock(&mddev->reconfig_mutex);
Expand Down Expand Up @@ -2996,6 +3000,23 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
/* Looks like we have a winner */
mddev_suspend(mddev);
mddev->pers->stop(mddev);

if (mddev->pers->sync_request == NULL &&
pers->sync_request != NULL) {
/* need to add the md_redundancy_group */
if (sysfs_create_group(&mddev->kobj, &md_redundancy_group))
printk(KERN_WARNING
"md: cannot register extra attributes for %s\n",
mdname(mddev));
mddev->sysfs_action = sysfs_get_dirent(mddev->kobj.sd, "sync_action");
}
if (mddev->pers->sync_request != NULL &&
pers->sync_request == NULL) {
/* need to remove the md_redundancy_group */
if (mddev->to_remove == NULL)
mddev->to_remove = &md_redundancy_group;
}

module_put(mddev->pers->owner);
/* Invalidate devices that are now superfluous */
list_for_each_entry(rdev, &mddev->disks, same_set)
Expand Down Expand Up @@ -4550,8 +4571,8 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
mddev->queue->unplug_fn = NULL;
mddev->queue->backing_dev_info.congested_fn = NULL;
module_put(mddev->pers->owner);
if (mddev->pers->sync_request && mddev->private == NULL)
mddev->private = (void*)1;
if (mddev->pers->sync_request && mddev->to_remove == NULL)
mddev->to_remove = &md_redundancy_group;
mddev->pers = NULL;
/* tell userspace to handle 'inactive' */
sysfs_notify_dirent(mddev->sysfs_state);
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/md/md.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ struct mddev_s
atomic_t max_corr_read_errors; /* max read retries */
struct list_head all_mddevs;

struct attribute_group *to_remove;
/* Generic barrier handling.
* If there is a pending barrier request, all other
* writes are blocked while the devices are flushed.
Expand Down
7 changes: 5 additions & 2 deletions trunk/drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -5090,7 +5090,9 @@ static int run(mddev_t *mddev)
}

/* Ok, everything is just fine now */
if (sysfs_create_group(&mddev->kobj, &raid5_attrs_group))
if (mddev->to_remove == &raid5_attrs_group)
mddev->to_remove = NULL;
else if (sysfs_create_group(&mddev->kobj, &raid5_attrs_group))
printk(KERN_WARNING
"raid5: failed to create sysfs attributes for %s\n",
mdname(mddev));
Expand Down Expand Up @@ -5137,7 +5139,8 @@ static int stop(mddev_t *mddev)
mddev->queue->backing_dev_info.congested_fn = NULL;
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
free_conf(conf);
mddev->private = &raid5_attrs_group;
mddev->private = NULL;
mddev->to_remove = &raid5_attrs_group;
return 0;
}

Expand Down

0 comments on commit 76eedc1

Please sign in to comment.