Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 154711
b: refs/heads/master
c: 0909dc4
h: refs/heads/master
i:
  154709: f4ff9ba
  154707: de3b53a
  154703: 625eb32
v: v3
  • Loading branch information
NeilBrown committed Jul 1, 2009
1 parent 03cae05 commit 992c0b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 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: 1ec22eb2b4a2e1a763106bce36b11c02eaa84e61
refs/heads/master: 0909dc448c98ed5021c87ffdfc09fb473aa464ab
38 changes: 18 additions & 20 deletions trunk/drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -3846,11 +3846,9 @@ static int md_alloc(dev_t dev, char *name)
flush_scheduled_work();

mutex_lock(&disks_mutex);
if (mddev->gendisk) {
mutex_unlock(&disks_mutex);
mddev_put(mddev);
return -EEXIST;
}
error = -EEXIST;
if (mddev->gendisk)
goto abort;

if (name) {
/* Need to ensure that 'name' is not a duplicate.
Expand All @@ -3862,19 +3860,15 @@ static int md_alloc(dev_t dev, char *name)
if (mddev2->gendisk &&
strcmp(mddev2->gendisk->disk_name, name) == 0) {
spin_unlock(&all_mddevs_lock);
mutex_unlock(&disks_mutex);
mddev_put(mddev);
return -EEXIST;
goto abort;
}
spin_unlock(&all_mddevs_lock);
}

error = -ENOMEM;
mddev->queue = blk_alloc_queue(GFP_KERNEL);
if (!mddev->queue) {
mutex_unlock(&disks_mutex);
mddev_put(mddev);
return -ENOMEM;
}
if (!mddev->queue)
goto abort;
mddev->queue->queuedata = mddev;

/* Can be unlocked because the queue is new: no concurrency */
Expand All @@ -3884,11 +3878,9 @@ static int md_alloc(dev_t dev, char *name)

disk = alloc_disk(1 << shift);
if (!disk) {
mutex_unlock(&disks_mutex);
blk_cleanup_queue(mddev->queue);
mddev->queue = NULL;
mddev_put(mddev);
return -ENOMEM;
goto abort;
}
disk->major = MAJOR(mddev->unit);
disk->first_minor = unit << shift;
Expand All @@ -3910,16 +3902,22 @@ static int md_alloc(dev_t dev, char *name)
mddev->gendisk = disk;
error = kobject_init_and_add(&mddev->kobj, &md_ktype,
&disk_to_dev(disk)->kobj, "%s", "md");
mutex_unlock(&disks_mutex);
if (error)
if (error) {
/* This isn't possible, but as kobject_init_and_add is marked
* __must_check, we must do something with the result
*/
printk(KERN_WARNING "md: cannot register %s/md - name in use\n",
disk->disk_name);
else {
error = 0;
}
abort:
mutex_unlock(&disks_mutex);
if (!error) {
kobject_uevent(&mddev->kobj, KOBJ_ADD);
mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state");
}
mddev_put(mddev);
return 0;
return error;
}

static struct kobject *md_probe(dev_t dev, int *part, void *data)
Expand Down

0 comments on commit 992c0b4

Please sign in to comment.