diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 09be637d52cb..d4351ff0849f 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1756,9 +1756,10 @@ static void print_sb_1(struct mdp_superblock_1 *sb) | |||
1756 | __u8 *uuid; | 1756 | __u8 *uuid; |
1757 | 1757 | ||
1758 | uuid = sb->set_uuid; | 1758 | uuid = sb->set_uuid; |
1759 | printk(KERN_INFO "md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x" | 1759 | printk(KERN_INFO |
1760 | ":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n" | 1760 | "md: SB: (V:%u) (F:0x%08x) Array-ID:<%02x%02x%02x%02x" |
1761 | KERN_INFO "md: Name: \"%s\" CT:%llu\n", | 1761 | ":%02x%02x:%02x%02x:%02x%02x:%02x%02x%02x%02x%02x%02x>\n" |
1762 | "md: Name: \"%s\" CT:%llu\n", | ||
1762 | le32_to_cpu(sb->major_version), | 1763 | le32_to_cpu(sb->major_version), |
1763 | le32_to_cpu(sb->feature_map), | 1764 | le32_to_cpu(sb->feature_map), |
1764 | uuid[0], uuid[1], uuid[2], uuid[3], | 1765 | uuid[0], uuid[1], uuid[2], uuid[3], |
@@ -1770,12 +1771,13 @@ static void print_sb_1(struct mdp_superblock_1 *sb) | |||
1770 | & MD_SUPERBLOCK_1_TIME_SEC_MASK); | 1771 | & MD_SUPERBLOCK_1_TIME_SEC_MASK); |
1771 | 1772 | ||
1772 | uuid = sb->device_uuid; | 1773 | uuid = sb->device_uuid; |
1773 | printk(KERN_INFO "md: L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu" | 1774 | printk(KERN_INFO |
1775 | "md: L%u SZ%llu RD:%u LO:%u CS:%u DO:%llu DS:%llu SO:%llu" | ||
1774 | " RO:%llu\n" | 1776 | " RO:%llu\n" |
1775 | KERN_INFO "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x" | 1777 | "md: Dev:%08x UUID: %02x%02x%02x%02x:%02x%02x:%02x%02x:%02x%02x" |
1776 | ":%02x%02x%02x%02x%02x%02x\n" | 1778 | ":%02x%02x%02x%02x%02x%02x\n" |
1777 | KERN_INFO "md: (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n" | 1779 | "md: (F:0x%08x) UT:%llu Events:%llu ResyncOffset:%llu CSUM:0x%08x\n" |
1778 | KERN_INFO "md: (MaxDev:%u) \n", | 1780 | "md: (MaxDev:%u) \n", |
1779 | le32_to_cpu(sb->level), | 1781 | le32_to_cpu(sb->level), |
1780 | (unsigned long long)le64_to_cpu(sb->size), | 1782 | (unsigned long long)le64_to_cpu(sb->size), |
1781 | le32_to_cpu(sb->raid_disks), | 1783 | le32_to_cpu(sb->raid_disks), |
@@ -3573,7 +3575,8 @@ suspend_lo_store(mddev_t *mddev, const char *buf, size_t len) | |||
3573 | char *e; | 3575 | char *e; |
3574 | unsigned long long new = simple_strtoull(buf, &e, 10); | 3576 | unsigned long long new = simple_strtoull(buf, &e, 10); |
3575 | 3577 | ||
3576 | if (mddev->pers->quiesce == NULL) | 3578 | if (mddev->pers == NULL || |
3579 | mddev->pers->quiesce == NULL) | ||
3577 | return -EINVAL; | 3580 | return -EINVAL; |
3578 | if (buf == e || (*e && *e != '\n')) | 3581 | if (buf == e || (*e && *e != '\n')) |
3579 | return -EINVAL; | 3582 | return -EINVAL; |
@@ -3601,7 +3604,8 @@ suspend_hi_store(mddev_t *mddev, const char *buf, size_t len) | |||
3601 | char *e; | 3604 | char *e; |
3602 | unsigned long long new = simple_strtoull(buf, &e, 10); | 3605 | unsigned long long new = simple_strtoull(buf, &e, 10); |
3603 | 3606 | ||
3604 | if (mddev->pers->quiesce == NULL) | 3607 | if (mddev->pers == NULL || |
3608 | mddev->pers->quiesce == NULL) | ||
3605 | return -EINVAL; | 3609 | return -EINVAL; |
3606 | if (buf == e || (*e && *e != '\n')) | 3610 | if (buf == e || (*e && *e != '\n')) |
3607 | return -EINVAL; | 3611 | return -EINVAL; |
@@ -3844,11 +3848,9 @@ static int md_alloc(dev_t dev, char *name) | |||
3844 | flush_scheduled_work(); | 3848 | flush_scheduled_work(); |
3845 | 3849 | ||
3846 | mutex_lock(&disks_mutex); | 3850 | mutex_lock(&disks_mutex); |
3847 | if (mddev->gendisk) { | 3851 | error = -EEXIST; |
3848 | mutex_unlock(&disks_mutex); | 3852 | if (mddev->gendisk) |
3849 | mddev_put(mddev); | 3853 | goto abort; |
3850 | return -EEXIST; | ||
3851 | } | ||
3852 | 3854 | ||
3853 | if (name) { | 3855 | if (name) { |
3854 | /* Need to ensure that 'name' is not a duplicate. | 3856 | /* Need to ensure that 'name' is not a duplicate. |
@@ -3860,17 +3862,15 @@ static int md_alloc(dev_t dev, char *name) | |||
3860 | if (mddev2->gendisk && | 3862 | if (mddev2->gendisk && |
3861 | strcmp(mddev2->gendisk->disk_name, name) == 0) { | 3863 | strcmp(mddev2->gendisk->disk_name, name) == 0) { |
3862 | spin_unlock(&all_mddevs_lock); | 3864 | spin_unlock(&all_mddevs_lock); |
3863 | return -EEXIST; | 3865 | goto abort; |
3864 | } | 3866 | } |
3865 | spin_unlock(&all_mddevs_lock); | 3867 | spin_unlock(&all_mddevs_lock); |
3866 | } | 3868 | } |
3867 | 3869 | ||
3870 | error = -ENOMEM; | ||
3868 | mddev->queue = blk_alloc_queue(GFP_KERNEL); | 3871 | mddev->queue = blk_alloc_queue(GFP_KERNEL); |
3869 | if (!mddev->queue) { | 3872 | if (!mddev->queue) |
3870 | mutex_unlock(&disks_mutex); | 3873 | goto abort; |
3871 | mddev_put(mddev); | ||
3872 | return -ENOMEM; | ||
3873 | } | ||
3874 | mddev->queue->queuedata = mddev; | 3874 | mddev->queue->queuedata = mddev; |
3875 | 3875 | ||
3876 | /* Can be unlocked because the queue is new: no concurrency */ | 3876 | /* Can be unlocked because the queue is new: no concurrency */ |
@@ -3880,11 +3880,9 @@ static int md_alloc(dev_t dev, char *name) | |||
3880 | 3880 | ||
3881 | disk = alloc_disk(1 << shift); | 3881 | disk = alloc_disk(1 << shift); |
3882 | if (!disk) { | 3882 | if (!disk) { |
3883 | mutex_unlock(&disks_mutex); | ||
3884 | blk_cleanup_queue(mddev->queue); | 3883 | blk_cleanup_queue(mddev->queue); |
3885 | mddev->queue = NULL; | 3884 | mddev->queue = NULL; |
3886 | mddev_put(mddev); | 3885 | goto abort; |
3887 | return -ENOMEM; | ||
3888 | } | 3886 | } |
3889 | disk->major = MAJOR(mddev->unit); | 3887 | disk->major = MAJOR(mddev->unit); |
3890 | disk->first_minor = unit << shift; | 3888 | disk->first_minor = unit << shift; |
@@ -3906,16 +3904,22 @@ static int md_alloc(dev_t dev, char *name) | |||
3906 | mddev->gendisk = disk; | 3904 | mddev->gendisk = disk; |
3907 | error = kobject_init_and_add(&mddev->kobj, &md_ktype, | 3905 | error = kobject_init_and_add(&mddev->kobj, &md_ktype, |
3908 | &disk_to_dev(disk)->kobj, "%s", "md"); | 3906 | &disk_to_dev(disk)->kobj, "%s", "md"); |
3909 | mutex_unlock(&disks_mutex); | 3907 | if (error) { |
3910 | if (error) | 3908 | /* This isn't possible, but as kobject_init_and_add is marked |
3909 | * __must_check, we must do something with the result | ||
3910 | */ | ||
3911 | printk(KERN_WARNING "md: cannot register %s/md - name in use\n", | 3911 | printk(KERN_WARNING "md: cannot register %s/md - name in use\n", |
3912 | disk->disk_name); | 3912 | disk->disk_name); |
3913 | else { | 3913 | error = 0; |
3914 | } | ||
3915 | abort: | ||
3916 | mutex_unlock(&disks_mutex); | ||
3917 | if (!error) { | ||
3914 | kobject_uevent(&mddev->kobj, KOBJ_ADD); | 3918 | kobject_uevent(&mddev->kobj, KOBJ_ADD); |
3915 | mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state"); | 3919 | mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state"); |
3916 | } | 3920 | } |
3917 | mddev_put(mddev); | 3921 | mddev_put(mddev); |
3918 | return 0; | 3922 | return error; |
3919 | } | 3923 | } |
3920 | 3924 | ||
3921 | static struct kobject *md_probe(dev_t dev, int *part, void *data) | 3925 | static struct kobject *md_probe(dev_t dev, int *part, void *data) |
@@ -6334,10 +6338,16 @@ void md_do_sync(mddev_t *mddev) | |||
6334 | sysfs_notify(&mddev->kobj, NULL, "sync_completed"); | 6338 | sysfs_notify(&mddev->kobj, NULL, "sync_completed"); |
6335 | } | 6339 | } |
6336 | 6340 | ||
6337 | if (j >= mddev->resync_max) | 6341 | while (j >= mddev->resync_max && !kthread_should_stop()) { |
6338 | wait_event(mddev->recovery_wait, | 6342 | /* As this condition is controlled by user-space, |
6339 | mddev->resync_max > j | 6343 | * we can block indefinitely, so use '_interruptible' |
6340 | || kthread_should_stop()); | 6344 | * to avoid triggering warnings. |
6345 | */ | ||
6346 | flush_signals(current); /* just in case */ | ||
6347 | wait_event_interruptible(mddev->recovery_wait, | ||
6348 | mddev->resync_max > j | ||
6349 | || kthread_should_stop()); | ||
6350 | } | ||
6341 | 6351 | ||
6342 | if (kthread_should_stop()) | 6352 | if (kthread_should_stop()) |
6343 | goto interrupted; | 6353 | goto interrupted; |