diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 612343fdde94..fccc8343a250 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -3066,11 +3066,8 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len) | |||
3066 | } else | 3066 | } else |
3067 | err = -EBUSY; | 3067 | err = -EBUSY; |
3068 | spin_unlock_irq(&mddev->write_lock); | 3068 | spin_unlock_irq(&mddev->write_lock); |
3069 | } else { | 3069 | } else |
3070 | mddev->ro = 0; | 3070 | err = -EINVAL; |
3071 | mddev->recovery_cp = MaxSector; | ||
3072 | err = do_md_run(mddev); | ||
3073 | } | ||
3074 | break; | 3071 | break; |
3075 | case active: | 3072 | case active: |
3076 | if (mddev->pers) { | 3073 | if (mddev->pers) { |
@@ -4297,6 +4294,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
4297 | { | 4294 | { |
4298 | int err = 0; | 4295 | int err = 0; |
4299 | struct gendisk *disk = mddev->gendisk; | 4296 | struct gendisk *disk = mddev->gendisk; |
4297 | mdk_rdev_t *rdev; | ||
4300 | 4298 | ||
4301 | if (atomic_read(&mddev->openers) > is_open) { | 4299 | if (atomic_read(&mddev->openers) > is_open) { |
4302 | printk("md: %s still in use.\n",mdname(mddev)); | 4300 | printk("md: %s still in use.\n",mdname(mddev)); |
@@ -4339,6 +4337,13 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
4339 | /* tell userspace to handle 'inactive' */ | 4337 | /* tell userspace to handle 'inactive' */ |
4340 | sysfs_notify_dirent(mddev->sysfs_state); | 4338 | sysfs_notify_dirent(mddev->sysfs_state); |
4341 | 4339 | ||
4340 | list_for_each_entry(rdev, &mddev->disks, same_set) | ||
4341 | if (rdev->raid_disk >= 0) { | ||
4342 | char nm[20]; | ||
4343 | sprintf(nm, "rd%d", rdev->raid_disk); | ||
4344 | sysfs_remove_link(&mddev->kobj, nm); | ||
4345 | } | ||
4346 | |||
4342 | set_capacity(disk, 0); | 4347 | set_capacity(disk, 0); |
4343 | mddev->changed = 1; | 4348 | mddev->changed = 1; |
4344 | 4349 | ||
@@ -4359,7 +4364,6 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
4359 | * Free resources if final stop | 4364 | * Free resources if final stop |
4360 | */ | 4365 | */ |
4361 | if (mode == 0) { | 4366 | if (mode == 0) { |
4362 | mdk_rdev_t *rdev; | ||
4363 | 4367 | ||
4364 | printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); | 4368 | printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); |
4365 | 4369 | ||
@@ -4371,13 +4375,6 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open) | |||
4371 | } | 4375 | } |
4372 | mddev->bitmap_offset = 0; | 4376 | mddev->bitmap_offset = 0; |
4373 | 4377 | ||
4374 | list_for_each_entry(rdev, &mddev->disks, same_set) | ||
4375 | if (rdev->raid_disk >= 0) { | ||
4376 | char nm[20]; | ||
4377 | sprintf(nm, "rd%d", rdev->raid_disk); | ||
4378 | sysfs_remove_link(&mddev->kobj, nm); | ||
4379 | } | ||
4380 | |||
4381 | /* make sure all md_delayed_delete calls have finished */ | 4378 | /* make sure all md_delayed_delete calls have finished */ |
4382 | flush_scheduled_work(); | 4379 | flush_scheduled_work(); |
4383 | 4380 | ||
@@ -5705,37 +5702,38 @@ static void status_unused(struct seq_file *seq) | |||
5705 | 5702 | ||
5706 | static void status_resync(struct seq_file *seq, mddev_t * mddev) | 5703 | static void status_resync(struct seq_file *seq, mddev_t * mddev) |
5707 | { | 5704 | { |
5708 | sector_t max_blocks, resync, res; | 5705 | sector_t max_sectors, resync, res; |
5709 | unsigned long dt, db, rt; | 5706 | unsigned long dt, db; |
5707 | sector_t rt; | ||
5710 | int scale; | 5708 | int scale; |
5711 | unsigned int per_milli; | 5709 | unsigned int per_milli; |
5712 | 5710 | ||
5713 | resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active))/2; | 5711 | resync = mddev->curr_resync - atomic_read(&mddev->recovery_active); |
5714 | 5712 | ||
5715 | if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) | 5713 | if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) |
5716 | max_blocks = mddev->resync_max_sectors >> 1; | 5714 | max_sectors = mddev->resync_max_sectors; |
5717 | else | 5715 | else |
5718 | max_blocks = mddev->dev_sectors / 2; | 5716 | max_sectors = mddev->dev_sectors; |
5719 | 5717 | ||
5720 | /* | 5718 | /* |
5721 | * Should not happen. | 5719 | * Should not happen. |
5722 | */ | 5720 | */ |
5723 | if (!max_blocks) { | 5721 | if (!max_sectors) { |
5724 | MD_BUG(); | 5722 | MD_BUG(); |
5725 | return; | 5723 | return; |
5726 | } | 5724 | } |
5727 | /* Pick 'scale' such that (resync>>scale)*1000 will fit | 5725 | /* Pick 'scale' such that (resync>>scale)*1000 will fit |
5728 | * in a sector_t, and (max_blocks>>scale) will fit in a | 5726 | * in a sector_t, and (max_sectors>>scale) will fit in a |
5729 | * u32, as those are the requirements for sector_div. | 5727 | * u32, as those are the requirements for sector_div. |
5730 | * Thus 'scale' must be at least 10 | 5728 | * Thus 'scale' must be at least 10 |
5731 | */ | 5729 | */ |
5732 | scale = 10; | 5730 | scale = 10; |
5733 | if (sizeof(sector_t) > sizeof(unsigned long)) { | 5731 | if (sizeof(sector_t) > sizeof(unsigned long)) { |
5734 | while ( max_blocks/2 > (1ULL<<(scale+32))) | 5732 | while ( max_sectors/2 > (1ULL<<(scale+32))) |
5735 | scale++; | 5733 | scale++; |
5736 | } | 5734 | } |
5737 | res = (resync>>scale)*1000; | 5735 | res = (resync>>scale)*1000; |
5738 | sector_div(res, (u32)((max_blocks>>scale)+1)); | 5736 | sector_div(res, (u32)((max_sectors>>scale)+1)); |
5739 | 5737 | ||
5740 | per_milli = res; | 5738 | per_milli = res; |
5741 | { | 5739 | { |
@@ -5756,25 +5754,35 @@ static void status_resync(struct seq_file *seq, mddev_t * mddev) | |||
5756 | (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ? | 5754 | (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ? |
5757 | "resync" : "recovery"))), | 5755 | "resync" : "recovery"))), |
5758 | per_milli/10, per_milli % 10, | 5756 | per_milli/10, per_milli % 10, |
5759 | (unsigned long long) resync, | 5757 | (unsigned long long) resync/2, |
5760 | (unsigned long long) max_blocks); | 5758 | (unsigned long long) max_sectors/2); |
5761 | 5759 | ||
5762 | /* | 5760 | /* |
5763 | * We do not want to overflow, so the order of operands and | ||
5764 | * the * 100 / 100 trick are important. We do a +1 to be | ||
5765 | * safe against division by zero. We only estimate anyway. | ||
5766 | * | ||
5767 | * dt: time from mark until now | 5761 | * dt: time from mark until now |
5768 | * db: blocks written from mark until now | 5762 | * db: blocks written from mark until now |
5769 | * rt: remaining time | 5763 | * rt: remaining time |
5764 | * | ||
5765 | * rt is a sector_t, so could be 32bit or 64bit. | ||
5766 | * So we divide before multiply in case it is 32bit and close | ||
5767 | * to the limit. | ||
5768 | * We scale the divisor (db) by 32 to avoid loosing precision | ||
5769 | * near the end of resync when the number of remaining sectors | ||
5770 | * is close to 'db'. | ||
5771 | * We then divide rt by 32 after multiplying by db to compensate. | ||
5772 | * The '+1' avoids division by zero if db is very small. | ||
5770 | */ | 5773 | */ |
5771 | dt = ((jiffies - mddev->resync_mark) / HZ); | 5774 | dt = ((jiffies - mddev->resync_mark) / HZ); |
5772 | if (!dt) dt++; | 5775 | if (!dt) dt++; |
5773 | db = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active)) | 5776 | db = (mddev->curr_mark_cnt - atomic_read(&mddev->recovery_active)) |
5774 | - mddev->resync_mark_cnt; | 5777 | - mddev->resync_mark_cnt; |
5775 | rt = (dt * ((unsigned long)(max_blocks-resync) / (db/2/100+1)))/100; | ||
5776 | 5778 | ||
5777 | seq_printf(seq, " finish=%lu.%lumin", rt / 60, (rt % 60)/6); | 5779 | rt = max_sectors - resync; /* number of remaining sectors */ |
5780 | sector_div(rt, db/32+1); | ||
5781 | rt *= dt; | ||
5782 | rt >>= 5; | ||
5783 | |||
5784 | seq_printf(seq, " finish=%lu.%lumin", (unsigned long)rt / 60, | ||
5785 | ((unsigned long)rt % 60)/6); | ||
5778 | 5786 | ||
5779 | seq_printf(seq, " speed=%ldK/sec", db/2/dt); | 5787 | seq_printf(seq, " speed=%ldK/sec", db/2/dt); |
5780 | } | 5788 | } |
@@ -5965,7 +5973,7 @@ static int md_seq_show(struct seq_file *seq, void *v) | |||
5965 | return 0; | 5973 | return 0; |
5966 | } | 5974 | } |
5967 | 5975 | ||
5968 | static struct seq_operations md_seq_ops = { | 5976 | static const struct seq_operations md_seq_ops = { |
5969 | .start = md_seq_start, | 5977 | .start = md_seq_start, |
5970 | .next = md_seq_next, | 5978 | .next = md_seq_next, |
5971 | .stop = md_seq_stop, | 5979 | .stop = md_seq_stop, |