Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'md-3.11' of git://neil.brown.name/md

Pull md updates from NeilBrown:
"Mostly fixes, with a few minor features (eg 'last_sync_action' sysfs
file)

A couple marked for -stable including one recent bug which causes a
RAID10 reshape to complete without moving any data :-(

A couple more bugfixes (at least) to come, but haven't confirmed the
right solution yet."

* tag 'md-3.11' of git://neil.brown.name/md:
md/raid10: fix bug which causes all RAID10 reshapes to move no data.
md/raid5: allow 5-device RAID6 to be reshaped to 4-device.
md/raid10: fix two bugs affecting RAID10 reshape.
md: remove doubled description for sync_max, merging it within sync_min/sync_max
MD: Remember the last sync operation that was performed
md: fix buglet in RAID5 -> RAID0 conversion.
md/raid10: check In_sync flag in 'enough()'.
md/raid10: locking changes for 'enough()'.
md: replace strict_strto*() with kstrto*()
md: Wait for md_check_recovery before attempting device removal.
dm-raid: silence compiler warning on rebuilds_per_group.
DM RAID: Fix raid_resume not reviving failed devices in all cases
DM RAID: Break-up untidy function
DM RAID: Add ability to restore transiently failed devices on resume

+189 -72
+2
Documentation/device-mapper/dm-raid.txt
··· 222 222 1.4.2 Add RAID10 "far" and "offset" algorithm support. 223 223 1.5.0 Add message interface to allow manipulation of the sync_action. 224 224 New status (STATUSTYPE_INFO) fields: sync_action and mismatch_cnt. 225 + 1.5.1 Add ability to restore transiently failed devices on resume. 226 + 1.5.2 'mismatch_cnt' is zero unless [last_]sync_action is "check".
+6 -7
Documentation/md.txt
··· 566 566 when it reaches the current sync_max (below) and possibly at 567 567 other times. 568 568 569 - sync_max 570 - This is a number of sectors at which point a resync/recovery 571 - process will pause. When a resync is active, the value can 572 - only ever be increased, never decreased. The value of 'max' 573 - effectively disables the limit. 574 - 575 - 576 569 sync_speed 577 570 This shows the current actual speed, in K/sec, of the current 578 571 sync_action. It is averaged over the last 30 seconds. ··· 585 592 You can use 'select' or 'poll' on "sync_completed" to wait for 586 593 that number to reach sync_max. Then you can either increase 587 594 "sync_max", or can write 'idle' to "sync_action". 595 + 596 + The value of 'max' for "sync_max" effectively disables the limit. 597 + When a resync is active, the value can only ever be increased, 598 + never decreased. 599 + The value of '0' is the minimum for "sync_min". 600 + 588 601 589 602 590 603 Each active md device may also have attributes specific to the
+4 -4
drivers/md/bitmap.c
··· 2002 2002 } else { 2003 2003 int rv; 2004 2004 if (buf[0] == '+') 2005 - rv = strict_strtoll(buf+1, 10, &offset); 2005 + rv = kstrtoll(buf+1, 10, &offset); 2006 2006 else 2007 - rv = strict_strtoll(buf, 10, &offset); 2007 + rv = kstrtoll(buf, 10, &offset); 2008 2008 if (rv) 2009 2009 return rv; 2010 2010 if (offset == 0) ··· 2139 2139 backlog_store(struct mddev *mddev, const char *buf, size_t len) 2140 2140 { 2141 2141 unsigned long backlog; 2142 - int rv = strict_strtoul(buf, 10, &backlog); 2142 + int rv = kstrtoul(buf, 10, &backlog); 2143 2143 if (rv) 2144 2144 return rv; 2145 2145 if (backlog > COUNTER_MAX) ··· 2165 2165 unsigned long csize; 2166 2166 if (mddev->bitmap) 2167 2167 return -EBUSY; 2168 - rv = strict_strtoul(buf, 10, &csize); 2168 + rv = kstrtoul(buf, 10, &csize); 2169 2169 if (rv) 2170 2170 return rv; 2171 2171 if (csize < 512 ||
+70 -6
drivers/md/dm-raid.c
··· 380 380 static int validate_raid_redundancy(struct raid_set *rs) 381 381 { 382 382 unsigned i, rebuild_cnt = 0; 383 - unsigned rebuilds_per_group, copies, d; 383 + unsigned rebuilds_per_group = 0, copies, d; 384 384 unsigned group_size, last_group_start; 385 385 386 386 for (i = 0; i < rs->md.raid_disks; i++) ··· 504 504 * First, parse the in-order required arguments 505 505 * "chunk_size" is the only argument of this type. 506 506 */ 507 - if ((strict_strtoul(argv[0], 10, &value) < 0)) { 507 + if ((kstrtoul(argv[0], 10, &value) < 0)) { 508 508 rs->ti->error = "Bad chunk size"; 509 509 return -EINVAL; 510 510 } else if (rs->raid_type->level == 1) { ··· 585 585 continue; 586 586 } 587 587 588 - if (strict_strtoul(argv[i], 10, &value) < 0) { 588 + if (kstrtoul(argv[i], 10, &value) < 0) { 589 589 rs->ti->error = "Bad numerical argument given in raid params"; 590 590 return -EINVAL; 591 591 } ··· 1181 1181 argv++; 1182 1182 1183 1183 /* number of RAID parameters */ 1184 - if (strict_strtoul(argv[0], 10, &num_raid_params) < 0) { 1184 + if (kstrtoul(argv[0], 10, &num_raid_params) < 0) { 1185 1185 ti->error = "Cannot understand number of RAID parameters"; 1186 1186 return -EINVAL; 1187 1187 } ··· 1194 1194 return -EINVAL; 1195 1195 } 1196 1196 1197 - if ((strict_strtoul(argv[num_raid_params], 10, &num_raid_devs) < 0) || 1197 + if ((kstrtoul(argv[num_raid_params], 10, &num_raid_devs) < 0) || 1198 1198 (num_raid_devs >= INT_MAX)) { 1199 1199 ti->error = "Cannot understand number of raid devices"; 1200 1200 return -EINVAL; ··· 1388 1388 * performing a "check" of the array. 1389 1389 */ 1390 1390 DMEMIT(" %llu", 1391 + (strcmp(rs->md.last_sync_action, "check")) ? 0 : 1391 1392 (unsigned long long) 1392 1393 atomic64_read(&rs->md.resync_mismatches)); 1393 1394 break; ··· 1573 1572 mddev_suspend(&rs->md); 1574 1573 } 1575 1574 1575 + static void attempt_restore_of_faulty_devices(struct raid_set *rs) 1576 + { 1577 + int i; 1578 + uint64_t failed_devices, cleared_failed_devices = 0; 1579 + unsigned long flags; 1580 + struct dm_raid_superblock *sb; 1581 + struct md_rdev *r; 1582 + 1583 + for (i = 0; i < rs->md.raid_disks; i++) { 1584 + r = &rs->dev[i].rdev; 1585 + if (test_bit(Faulty, &r->flags) && r->sb_page && 1586 + sync_page_io(r, 0, r->sb_size, r->sb_page, READ, 1)) { 1587 + DMINFO("Faulty %s device #%d has readable super block." 1588 + " Attempting to revive it.", 1589 + rs->raid_type->name, i); 1590 + 1591 + /* 1592 + * Faulty bit may be set, but sometimes the array can 1593 + * be suspended before the personalities can respond 1594 + * by removing the device from the array (i.e. calling 1595 + * 'hot_remove_disk'). If they haven't yet removed 1596 + * the failed device, its 'raid_disk' number will be 1597 + * '>= 0' - meaning we must call this function 1598 + * ourselves. 1599 + */ 1600 + if ((r->raid_disk >= 0) && 1601 + (r->mddev->pers->hot_remove_disk(r->mddev, r) != 0)) 1602 + /* Failed to revive this device, try next */ 1603 + continue; 1604 + 1605 + r->raid_disk = i; 1606 + r->saved_raid_disk = i; 1607 + flags = r->flags; 1608 + clear_bit(Faulty, &r->flags); 1609 + clear_bit(WriteErrorSeen, &r->flags); 1610 + clear_bit(In_sync, &r->flags); 1611 + if (r->mddev->pers->hot_add_disk(r->mddev, r)) { 1612 + r->raid_disk = -1; 1613 + r->saved_raid_disk = -1; 1614 + r->flags = flags; 1615 + } else { 1616 + r->recovery_offset = 0; 1617 + cleared_failed_devices |= 1 << i; 1618 + } 1619 + } 1620 + } 1621 + if (cleared_failed_devices) { 1622 + rdev_for_each(r, &rs->md) { 1623 + sb = page_address(r->sb_page); 1624 + failed_devices = le64_to_cpu(sb->failed_devices); 1625 + failed_devices &= ~cleared_failed_devices; 1626 + sb->failed_devices = cpu_to_le64(failed_devices); 1627 + } 1628 + } 1629 + } 1630 + 1576 1631 static void raid_resume(struct dm_target *ti) 1577 1632 { 1578 1633 struct raid_set *rs = ti->private; ··· 1637 1580 if (!rs->bitmap_loaded) { 1638 1581 bitmap_load(&rs->md); 1639 1582 rs->bitmap_loaded = 1; 1583 + } else { 1584 + /* 1585 + * A secondary resume while the device is active. 1586 + * Take this opportunity to check whether any failed 1587 + * devices are reachable again. 1588 + */ 1589 + attempt_restore_of_faulty_devices(rs); 1640 1590 } 1641 1591 1642 1592 clear_bit(MD_RECOVERY_FROZEN, &rs->md.recovery); ··· 1652 1588 1653 1589 static struct target_type raid_target = { 1654 1590 .name = "raid", 1655 - .version = {1, 5, 0}, 1591 + .version = {1, 5, 2}, 1656 1592 .module = THIS_MODULE, 1657 1593 .ctr = raid_ctr, 1658 1594 .dtr = raid_dtr,
+37 -16
drivers/md/md.c
··· 521 521 init_waitqueue_head(&mddev->recovery_wait); 522 522 mddev->reshape_position = MaxSector; 523 523 mddev->reshape_backwards = 0; 524 + mddev->last_sync_action = "none"; 524 525 mddev->resync_min = 0; 525 526 mddev->resync_max = MaxSector; 526 527 mddev->level = LEVEL_NONE; ··· 2868 2867 offset_store(struct md_rdev *rdev, const char *buf, size_t len) 2869 2868 { 2870 2869 unsigned long long offset; 2871 - if (strict_strtoull(buf, 10, &offset) < 0) 2870 + if (kstrtoull(buf, 10, &offset) < 0) 2872 2871 return -EINVAL; 2873 2872 if (rdev->mddev->pers && rdev->raid_disk >= 0) 2874 2873 return -EBUSY; ··· 2896 2895 unsigned long long new_offset; 2897 2896 struct mddev *mddev = rdev->mddev; 2898 2897 2899 - if (strict_strtoull(buf, 10, &new_offset) < 0) 2898 + if (kstrtoull(buf, 10, &new_offset) < 0) 2900 2899 return -EINVAL; 2901 2900 2902 2901 if (mddev->sync_thread) ··· 2962 2961 unsigned long long blocks; 2963 2962 sector_t new; 2964 2963 2965 - if (strict_strtoull(buf, 10, &blocks) < 0) 2964 + if (kstrtoull(buf, 10, &blocks) < 0) 2966 2965 return -EINVAL; 2967 2966 2968 2967 if (blocks & 1ULL << (8 * sizeof(blocks) - 1)) ··· 3070 3069 3071 3070 if (cmd_match(buf, "none")) 3072 3071 recovery_start = MaxSector; 3073 - else if (strict_strtoull(buf, 10, &recovery_start)) 3072 + else if (kstrtoull(buf, 10, &recovery_start)) 3074 3073 return -EINVAL; 3075 3074 3076 3075 if (rdev->mddev->pers && ··· 3498 3497 if (clevel[len-1] == '\n') 3499 3498 len--; 3500 3499 clevel[len] = 0; 3501 - if (strict_strtol(clevel, 10, &level)) 3500 + if (kstrtol(clevel, 10, &level)) 3502 3501 level = LEVEL_NONE; 3503 3502 3504 3503 if (request_module("md-%s", clevel) != 0) ··· 4273 4272 return len; 4274 4273 } 4275 4274 4275 + static struct md_sysfs_entry md_scan_mode = 4276 + __ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store); 4277 + 4278 + static ssize_t 4279 + last_sync_action_show(struct mddev *mddev, char *page) 4280 + { 4281 + return sprintf(page, "%s\n", mddev->last_sync_action); 4282 + } 4283 + 4284 + static struct md_sysfs_entry md_last_scan_mode = __ATTR_RO(last_sync_action); 4285 + 4276 4286 static ssize_t 4277 4287 mismatch_cnt_show(struct mddev *mddev, char *page) 4278 4288 { ··· 4291 4279 (unsigned long long) 4292 4280 atomic64_read(&mddev->resync_mismatches)); 4293 4281 } 4294 - 4295 - static struct md_sysfs_entry md_scan_mode = 4296 - __ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store); 4297 - 4298 4282 4299 4283 static struct md_sysfs_entry md_mismatches = __ATTR_RO(mismatch_cnt); 4300 4284 ··· 4364 4356 { 4365 4357 long n; 4366 4358 4367 - if (strict_strtol(buf, 10, &n)) 4359 + if (kstrtol(buf, 10, &n)) 4368 4360 return -EINVAL; 4369 4361 4370 4362 if (n != 0 && n != 1) ··· 4432 4424 min_sync_store(struct mddev *mddev, const char *buf, size_t len) 4433 4425 { 4434 4426 unsigned long long min; 4435 - if (strict_strtoull(buf, 10, &min)) 4427 + if (kstrtoull(buf, 10, &min)) 4436 4428 return -EINVAL; 4437 4429 if (min > mddev->resync_max) 4438 4430 return -EINVAL; ··· 4469 4461 mddev->resync_max = MaxSector; 4470 4462 else { 4471 4463 unsigned long long max; 4472 - if (strict_strtoull(buf, 10, &max)) 4464 + if (kstrtoull(buf, 10, &max)) 4473 4465 return -EINVAL; 4474 4466 if (max < mddev->resync_min) 4475 4467 return -EINVAL; ··· 4694 4686 4695 4687 static struct attribute *md_redundancy_attrs[] = { 4696 4688 &md_scan_mode.attr, 4689 + &md_last_scan_mode.attr, 4697 4690 &md_mismatches.attr, 4698 4691 &md_sync_min.attr, 4699 4692 &md_sync_max.attr, ··· 6414 6405 /* need to ensure md_delayed_delete() has completed */ 6415 6406 flush_workqueue(md_misc_wq); 6416 6407 6408 + if (cmd == HOT_REMOVE_DISK) 6409 + /* need to ensure recovery thread has run */ 6410 + wait_event_interruptible_timeout(mddev->sb_wait, 6411 + !test_bit(MD_RECOVERY_NEEDED, 6412 + &mddev->flags), 6413 + msecs_to_jiffies(5000)); 6417 6414 err = mddev_lock(mddev); 6418 6415 if (err) { 6419 6416 printk(KERN_INFO ··· 7338 7323 sector_t last_check; 7339 7324 int skipped = 0; 7340 7325 struct md_rdev *rdev; 7341 - char *desc; 7326 + char *desc, *action = NULL; 7342 7327 struct blk_plug plug; 7343 7328 7344 7329 /* just incase thread restarts... */ ··· 7348 7333 return; 7349 7334 7350 7335 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { 7351 - if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) 7336 + if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) { 7352 7337 desc = "data-check"; 7353 - else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) 7338 + action = "check"; 7339 + } else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { 7354 7340 desc = "requested-resync"; 7355 - else 7341 + action = "repair"; 7342 + } else 7356 7343 desc = "resync"; 7357 7344 } else if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)) 7358 7345 desc = "reshape"; 7359 7346 else 7360 7347 desc = "recovery"; 7348 + 7349 + mddev->last_sync_action = action ?: desc; 7361 7350 7362 7351 /* we overload curr_resync somewhat here. 7363 7352 * 0 == not engaged in resync at all ··· 7911 7892 md_new_event(mddev); 7912 7893 } 7913 7894 unlock: 7895 + wake_up(&mddev->sb_wait); 7896 + 7914 7897 if (!mddev->sync_thread) { 7915 7898 clear_bit(MD_RECOVERY_RUNNING, &mddev->recovery); 7916 7899 if (test_and_clear_bit(MD_RECOVERY_RECOVER,
+8
drivers/md/md.h
··· 268 268 269 269 struct md_thread *thread; /* management thread */ 270 270 struct md_thread *sync_thread; /* doing resync or reconstruct */ 271 + 272 + /* 'last_sync_action' is initialized to "none". It is set when a 273 + * sync operation (i.e "data-check", "requested-resync", "resync", 274 + * "recovery", or "reshape") is started. It holds this value even 275 + * when the sync thread is "frozen" (interrupted) or "idle" (stopped 276 + * or finished). It is overwritten when a new sync operation is begun. 277 + */ 278 + char *last_sync_action; 271 279 sector_t curr_resync; /* last block scheduled */ 272 280 /* As resync requests can complete out of order, we cannot easily track 273 281 * how much resync has been completed. So we occasionally pause until
+1
drivers/md/raid0.c
··· 597 597 mdname(mddev)); 598 598 return ERR_PTR(-EINVAL); 599 599 } 600 + rdev->sectors = mddev->dev_sectors; 600 601 } 601 602 602 603 /* Set new parameters */
+4 -3
drivers/md/raid1.c
··· 1519 1519 p = conf->mirrors+mirror; 1520 1520 if (!p->rdev) { 1521 1521 1522 - disk_stack_limits(mddev->gendisk, rdev->bdev, 1523 - rdev->data_offset << 9); 1522 + if (mddev->gendisk) 1523 + disk_stack_limits(mddev->gendisk, rdev->bdev, 1524 + rdev->data_offset << 9); 1524 1525 1525 1526 p->head_position = 0; 1526 1527 rdev->raid_disk = mirror; ··· 1560 1559 clear_bit(Unmerged, &rdev->flags); 1561 1560 } 1562 1561 md_integrity_add_rdev(rdev, mddev); 1563 - if (blk_queue_discard(bdev_get_queue(rdev->bdev))) 1562 + if (mddev->queue && blk_queue_discard(bdev_get_queue(rdev->bdev))) 1564 1563 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue); 1565 1564 print_conf(conf); 1566 1565 return err;
+54 -33
drivers/md/raid10.c
··· 97 97 98 98 static void allow_barrier(struct r10conf *conf); 99 99 static void lower_barrier(struct r10conf *conf); 100 - static int enough(struct r10conf *conf, int ignore); 100 + static int _enough(struct r10conf *conf, int previous, int ignore); 101 101 static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, 102 102 int *skipped); 103 103 static void reshape_request_write(struct mddev *mddev, struct r10bio *r10_bio); ··· 392 392 * than fail the last device. Here we redefine 393 393 * "uptodate" to mean "Don't want to retry" 394 394 */ 395 - unsigned long flags; 396 - spin_lock_irqsave(&conf->device_lock, flags); 397 - if (!enough(conf, rdev->raid_disk)) 395 + if (!_enough(conf, test_bit(R10BIO_Previous, &r10_bio->state), 396 + rdev->raid_disk)) 398 397 uptodate = 1; 399 - spin_unlock_irqrestore(&conf->device_lock, flags); 400 398 } 401 399 if (uptodate) { 402 400 raid_end_bio_io(r10_bio); ··· 1630 1632 * Don't consider the device numbered 'ignore' 1631 1633 * as we might be about to remove it. 1632 1634 */ 1633 - static int _enough(struct r10conf *conf, struct geom *geo, int ignore) 1635 + static int _enough(struct r10conf *conf, int previous, int ignore) 1634 1636 { 1635 1637 int first = 0; 1638 + int has_enough = 0; 1639 + int disks, ncopies; 1640 + if (previous) { 1641 + disks = conf->prev.raid_disks; 1642 + ncopies = conf->prev.near_copies; 1643 + } else { 1644 + disks = conf->geo.raid_disks; 1645 + ncopies = conf->geo.near_copies; 1646 + } 1636 1647 1648 + rcu_read_lock(); 1637 1649 do { 1638 1650 int n = conf->copies; 1639 1651 int cnt = 0; 1640 1652 int this = first; 1641 1653 while (n--) { 1642 - if (conf->mirrors[this].rdev && 1643 - this != ignore) 1654 + struct md_rdev *rdev; 1655 + if (this != ignore && 1656 + (rdev = rcu_dereference(conf->mirrors[this].rdev)) && 1657 + test_bit(In_sync, &rdev->flags)) 1644 1658 cnt++; 1645 - this = (this+1) % geo->raid_disks; 1659 + this = (this+1) % disks; 1646 1660 } 1647 1661 if (cnt == 0) 1648 - return 0; 1649 - first = (first + geo->near_copies) % geo->raid_disks; 1662 + goto out; 1663 + first = (first + ncopies) % disks; 1650 1664 } while (first != 0); 1651 - return 1; 1665 + has_enough = 1; 1666 + out: 1667 + rcu_read_unlock(); 1668 + return has_enough; 1652 1669 } 1653 1670 1654 1671 static int enough(struct r10conf *conf, int ignore) 1655 1672 { 1656 - return _enough(conf, &conf->geo, ignore) && 1657 - _enough(conf, &conf->prev, ignore); 1673 + /* when calling 'enough', both 'prev' and 'geo' must 1674 + * be stable. 1675 + * This is ensured if ->reconfig_mutex or ->device_lock 1676 + * is held. 1677 + */ 1678 + return _enough(conf, 0, ignore) && 1679 + _enough(conf, 1, ignore); 1658 1680 } 1659 1681 1660 1682 static void error(struct mddev *mddev, struct md_rdev *rdev) 1661 1683 { 1662 1684 char b[BDEVNAME_SIZE]; 1663 1685 struct r10conf *conf = mddev->private; 1686 + unsigned long flags; 1664 1687 1665 1688 /* 1666 1689 * If it is not operational, then we have already marked it as dead ··· 1689 1670 * next level up know. 1690 1671 * else mark the drive as failed 1691 1672 */ 1673 + spin_lock_irqsave(&conf->device_lock, flags); 1692 1674 if (test_bit(In_sync, &rdev->flags) 1693 - && !enough(conf, rdev->raid_disk)) 1675 + && !enough(conf, rdev->raid_disk)) { 1694 1676 /* 1695 1677 * Don't fail the drive, just return an IO error. 1696 1678 */ 1697 - return; 1698 - if (test_and_clear_bit(In_sync, &rdev->flags)) { 1699 - unsigned long flags; 1700 - spin_lock_irqsave(&conf->device_lock, flags); 1701 - mddev->degraded++; 1702 1679 spin_unlock_irqrestore(&conf->device_lock, flags); 1703 - /* 1680 + return; 1681 + } 1682 + if (test_and_clear_bit(In_sync, &rdev->flags)) { 1683 + mddev->degraded++; 1684 + /* 1704 1685 * if recovery is running, make sure it aborts. 1705 1686 */ 1706 1687 set_bit(MD_RECOVERY_INTR, &mddev->recovery); ··· 1708 1689 set_bit(Blocked, &rdev->flags); 1709 1690 set_bit(Faulty, &rdev->flags); 1710 1691 set_bit(MD_CHANGE_DEVS, &mddev->flags); 1692 + spin_unlock_irqrestore(&conf->device_lock, flags); 1711 1693 printk(KERN_ALERT 1712 1694 "md/raid10:%s: Disk failure on %s, disabling device.\n" 1713 1695 "md/raid10:%s: Operation continuing on %d devices.\n", ··· 1811 1791 * very different from resync 1812 1792 */ 1813 1793 return -EBUSY; 1814 - if (rdev->saved_raid_disk < 0 && !_enough(conf, &conf->prev, -1)) 1794 + if (rdev->saved_raid_disk < 0 && !_enough(conf, 1, -1)) 1815 1795 return -EINVAL; 1816 1796 1817 1797 if (rdev->raid_disk >= 0) ··· 1839 1819 set_bit(Replacement, &rdev->flags); 1840 1820 rdev->raid_disk = mirror; 1841 1821 err = 0; 1842 - disk_stack_limits(mddev->gendisk, rdev->bdev, 1843 - rdev->data_offset << 9); 1822 + if (mddev->gendisk) 1823 + disk_stack_limits(mddev->gendisk, rdev->bdev, 1824 + rdev->data_offset << 9); 1844 1825 conf->fullsync = 1; 1845 1826 rcu_assign_pointer(p->replacement, rdev); 1846 1827 break; 1847 1828 } 1848 1829 1849 - disk_stack_limits(mddev->gendisk, rdev->bdev, 1850 - rdev->data_offset << 9); 1830 + if (mddev->gendisk) 1831 + disk_stack_limits(mddev->gendisk, rdev->bdev, 1832 + rdev->data_offset << 9); 1851 1833 1852 1834 p->head_position = 0; 1853 1835 p->recovery_disabled = mddev->recovery_disabled - 1; ··· 2931 2909 */ 2932 2910 if (mddev->bitmap == NULL && 2933 2911 mddev->recovery_cp == MaxSector && 2912 + mddev->reshape_position == MaxSector && 2913 + !test_bit(MD_RECOVERY_SYNC, &mddev->recovery) && 2934 2914 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) && 2915 + !test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && 2935 2916 conf->fullsync == 0) { 2936 2917 *skipped = 1; 2937 - max_sector = mddev->dev_sectors; 2938 - if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) || 2939 - test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)) 2940 - max_sector = mddev->resync_max_sectors; 2941 - return max_sector - sector_nr; 2918 + return mddev->dev_sectors - sector_nr; 2942 2919 } 2943 2920 2944 2921 skipped: ··· 3553 3532 3554 3533 /* FIXME calc properly */ 3555 3534 conf->mirrors = kzalloc(sizeof(struct raid10_info)*(mddev->raid_disks + 3556 - max(0,mddev->delta_disks)), 3535 + max(0,-mddev->delta_disks)), 3557 3536 GFP_KERNEL); 3558 3537 if (!conf->mirrors) 3559 3538 goto out; ··· 3712 3691 conf->geo.far_offset == 0) 3713 3692 goto out_free_conf; 3714 3693 if (conf->prev.far_copies != 1 && 3715 - conf->geo.far_offset == 0) 3694 + conf->prev.far_offset == 0) 3716 3695 goto out_free_conf; 3717 3696 } 3718 3697
+3 -3
drivers/md/raid5.c
··· 4924 4924 if (!conf) 4925 4925 return -ENODEV; 4926 4926 4927 - if (strict_strtoul(page, 10, &new)) 4927 + if (kstrtoul(page, 10, &new)) 4928 4928 return -EINVAL; 4929 4929 err = raid5_set_cache_size(mddev, new); 4930 4930 if (err) ··· 4957 4957 if (!conf) 4958 4958 return -ENODEV; 4959 4959 4960 - if (strict_strtoul(page, 10, &new)) 4960 + if (kstrtoul(page, 10, &new)) 4961 4961 return -EINVAL; 4962 4962 if (new > conf->max_nr_stripes) 4963 4963 return -EINVAL; ··· 5914 5914 return 0; /* nothing to do */ 5915 5915 if (has_failed(conf)) 5916 5916 return -EINVAL; 5917 - if (mddev->delta_disks < 0) { 5917 + if (mddev->delta_disks < 0 && mddev->reshape_position == MaxSector) { 5918 5918 /* We might be able to shrink, but the devices must 5919 5919 * be made bigger first. 5920 5920 * For raid6, 4 is the minimum size.