aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c47
1 files changed, 32 insertions, 15 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6352e84fd512..5a5aeb076313 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -287,6 +287,7 @@ static int md_make_request(struct request_queue *q, struct bio *bio)
287 mddev_t *mddev = q->queuedata; 287 mddev_t *mddev = q->queuedata;
288 int rv; 288 int rv;
289 int cpu; 289 int cpu;
290 unsigned int sectors;
290 291
291 if (mddev == NULL || mddev->pers == NULL 292 if (mddev == NULL || mddev->pers == NULL
292 || !mddev->ready) { 293 || !mddev->ready) {
@@ -311,12 +312,16 @@ static int md_make_request(struct request_queue *q, struct bio *bio)
311 atomic_inc(&mddev->active_io); 312 atomic_inc(&mddev->active_io);
312 rcu_read_unlock(); 313 rcu_read_unlock();
313 314
315 /*
316 * save the sectors now since our bio can
317 * go away inside make_request
318 */
319 sectors = bio_sectors(bio);
314 rv = mddev->pers->make_request(mddev, bio); 320 rv = mddev->pers->make_request(mddev, bio);
315 321
316 cpu = part_stat_lock(); 322 cpu = part_stat_lock();
317 part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); 323 part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]);
318 part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], 324 part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], sectors);
319 bio_sectors(bio));
320 part_stat_unlock(); 325 part_stat_unlock();
321 326
322 if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended) 327 if (atomic_dec_and_test(&mddev->active_io) && mddev->suspended)
@@ -1947,8 +1952,6 @@ static int lock_rdev(mdk_rdev_t *rdev, dev_t dev, int shared)
1947 __bdevname(dev, b)); 1952 __bdevname(dev, b));
1948 return PTR_ERR(bdev); 1953 return PTR_ERR(bdev);
1949 } 1954 }
1950 if (!shared)
1951 set_bit(AllReserved, &rdev->flags);
1952 rdev->bdev = bdev; 1955 rdev->bdev = bdev;
1953 return err; 1956 return err;
1954} 1957}
@@ -2465,6 +2468,9 @@ slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2465 if (rdev->raid_disk != -1) 2468 if (rdev->raid_disk != -1)
2466 return -EBUSY; 2469 return -EBUSY;
2467 2470
2471 if (test_bit(MD_RECOVERY_RUNNING, &rdev->mddev->recovery))
2472 return -EBUSY;
2473
2468 if (rdev->mddev->pers->hot_add_disk == NULL) 2474 if (rdev->mddev->pers->hot_add_disk == NULL)
2469 return -EINVAL; 2475 return -EINVAL;
2470 2476
@@ -2610,12 +2616,11 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
2610 2616
2611 mddev_lock(mddev); 2617 mddev_lock(mddev);
2612 list_for_each_entry(rdev2, &mddev->disks, same_set) 2618 list_for_each_entry(rdev2, &mddev->disks, same_set)
2613 if (test_bit(AllReserved, &rdev2->flags) || 2619 if (rdev->bdev == rdev2->bdev &&
2614 (rdev->bdev == rdev2->bdev && 2620 rdev != rdev2 &&
2615 rdev != rdev2 && 2621 overlaps(rdev->data_offset, rdev->sectors,
2616 overlaps(rdev->data_offset, rdev->sectors, 2622 rdev2->data_offset,
2617 rdev2->data_offset, 2623 rdev2->sectors)) {
2618 rdev2->sectors))) {
2619 overlap = 1; 2624 overlap = 1;
2620 break; 2625 break;
2621 } 2626 }
@@ -5578,6 +5583,8 @@ static int update_raid_disks(mddev_t *mddev, int raid_disks)
5578 mddev->delta_disks = raid_disks - mddev->raid_disks; 5583 mddev->delta_disks = raid_disks - mddev->raid_disks;
5579 5584
5580 rv = mddev->pers->check_reshape(mddev); 5585 rv = mddev->pers->check_reshape(mddev);
5586 if (rv < 0)
5587 mddev->delta_disks = 0;
5581 return rv; 5588 return rv;
5582} 5589}
5583 5590
@@ -6985,9 +6992,6 @@ void md_do_sync(mddev_t *mddev)
6985 } else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) 6992 } else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
6986 mddev->resync_min = mddev->curr_resync_completed; 6993 mddev->resync_min = mddev->curr_resync_completed;
6987 mddev->curr_resync = 0; 6994 mddev->curr_resync = 0;
6988 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery))
6989 mddev->curr_resync_completed = 0;
6990 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
6991 wake_up(&resync_wait); 6995 wake_up(&resync_wait);
6992 set_bit(MD_RECOVERY_DONE, &mddev->recovery); 6996 set_bit(MD_RECOVERY_DONE, &mddev->recovery);
6993 md_wakeup_thread(mddev->thread); 6997 md_wakeup_thread(mddev->thread);
@@ -7028,7 +7032,7 @@ static int remove_and_add_spares(mddev_t *mddev)
7028 } 7032 }
7029 } 7033 }
7030 7034
7031 if (mddev->degraded && ! mddev->ro && !mddev->recovery_disabled) { 7035 if (mddev->degraded && !mddev->recovery_disabled) {
7032 list_for_each_entry(rdev, &mddev->disks, same_set) { 7036 list_for_each_entry(rdev, &mddev->disks, same_set) {
7033 if (rdev->raid_disk >= 0 && 7037 if (rdev->raid_disk >= 0 &&
7034 !test_bit(In_sync, &rdev->flags) && 7038 !test_bit(In_sync, &rdev->flags) &&
@@ -7151,7 +7155,20 @@ void md_check_recovery(mddev_t *mddev)
7151 /* Only thing we do on a ro array is remove 7155 /* Only thing we do on a ro array is remove
7152 * failed devices. 7156 * failed devices.
7153 */ 7157 */
7154 remove_and_add_spares(mddev); 7158 mdk_rdev_t *rdev;
7159 list_for_each_entry(rdev, &mddev->disks, same_set)
7160 if (rdev->raid_disk >= 0 &&
7161 !test_bit(Blocked, &rdev->flags) &&
7162 test_bit(Faulty, &rdev->flags) &&
7163 atomic_read(&rdev->nr_pending)==0) {
7164 if (mddev->pers->hot_remove_disk(
7165 mddev, rdev->raid_disk)==0) {
7166 char nm[20];
7167 sprintf(nm,"rd%d", rdev->raid_disk);
7168 sysfs_remove_link(&mddev->kobj, nm);
7169 rdev->raid_disk = -1;
7170 }
7171 }
7155 clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 7172 clear_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
7156 goto unlock; 7173 goto unlock;
7157 } 7174 }