Lines Matching refs:mddev

243 	struct mddev md;
261 struct mddev *mddev = &rs->md; in rs_config_backup() local
263 l->new_level = mddev->new_level; in rs_config_backup()
264 l->new_layout = mddev->new_layout; in rs_config_backup()
265 l->new_chunk_sectors = mddev->new_chunk_sectors; in rs_config_backup()
270 struct mddev *mddev = &rs->md; in rs_config_restore() local
272 mddev->new_level = l->new_level; in rs_config_restore()
273 mddev->new_layout = l->new_layout; in rs_config_restore()
274 mddev->new_chunk_sectors = l->new_chunk_sectors; in rs_config_restore()
684 struct mddev *mddev = &rs->md; in rs_set_rdev_sectors() local
691 rdev_for_each(rdev, mddev) in rs_set_rdev_sectors()
693 rdev->sectors = mddev->dev_sectors; in rs_set_rdev_sectors()
712 struct mddev *mddev = &rs->md; in rs_set_cur() local
714 mddev->new_level = mddev->level; in rs_set_cur()
715 mddev->new_layout = mddev->layout; in rs_set_cur()
716 mddev->new_chunk_sectors = mddev->chunk_sectors; in rs_set_cur()
725 struct mddev *mddev = &rs->md; in rs_set_new() local
727 mddev->level = mddev->new_level; in rs_set_new()
728 mddev->layout = mddev->new_layout; in rs_set_new()
729 mddev->chunk_sectors = mddev->new_chunk_sectors; in rs_set_new()
730 mddev->raid_disks = rs->raid_disks; in rs_set_new()
731 mddev->delta_disks = 0; in rs_set_new()
844 rs->dev[i].rdev.mddev = &rs->md; in parse_dev_params()
1264 jdev->mddev = &rs->md; in parse_raid_params()
1538 struct mddev *mddev = &rs->md; in rs_set_raid456_stripe_cache() local
1539 uint32_t min_stripes = max(mddev->chunk_sectors, mddev->new_chunk_sectors) / 2; in rs_set_raid456_stripe_cache()
1553 conf = mddev->private; in rs_set_raid456_stripe_cache()
1561 r = raid5_set_cache_size(mddev, nr_stripes); in rs_set_raid456_stripe_cache()
1628 struct mddev *mddev = &rs->md; in rs_set_dev_and_array_sectors() local
1631 delta_disks = mddev->delta_disks; in rs_set_dev_and_array_sectors()
1663 mddev->array_sectors = array_sectors; in rs_set_dev_and_array_sectors()
1664 mddev->dev_sectors = dev_sectors; in rs_set_dev_and_array_sectors()
1716 struct mddev *mddev = &rs->md; in rs_check_takeover() local
1729 switch (mddev->level) { in rs_check_takeover()
1732 if ((mddev->new_level == 1 || mddev->new_level == 5) && in rs_check_takeover()
1733 mddev->raid_disks == 1) in rs_check_takeover()
1737 if (mddev->new_level == 10 && in rs_check_takeover()
1738 !(rs->raid_disks % mddev->raid_disks)) in rs_check_takeover()
1742 if (__within_range(mddev->new_level, 4, 6) && in rs_check_takeover()
1743 mddev->new_layout == ALGORITHM_PARITY_N && in rs_check_takeover()
1744 mddev->raid_disks > 1) in rs_check_takeover()
1751 if (__is_raid10_offset(mddev->layout)) in rs_check_takeover()
1754 near_copies = __raid10_near_copies(mddev->layout); in rs_check_takeover()
1757 if (mddev->new_level == 0) { in rs_check_takeover()
1760 !(mddev->raid_disks % near_copies)) { in rs_check_takeover()
1761 mddev->raid_disks /= near_copies; in rs_check_takeover()
1762 mddev->delta_disks = mddev->raid_disks; in rs_check_takeover()
1768 __raid10_far_copies(mddev->layout) > 1) in rs_check_takeover()
1775 if (mddev->new_level == 1 && in rs_check_takeover()
1776 max(near_copies, __raid10_far_copies(mddev->layout)) == mddev->raid_disks) in rs_check_takeover()
1780 if (__within_range(mddev->new_level, 4, 5) && in rs_check_takeover()
1781 mddev->raid_disks == 2) in rs_check_takeover()
1787 if (__within_range(mddev->new_level, 4, 5) && in rs_check_takeover()
1788 mddev->raid_disks == 2) { in rs_check_takeover()
1789 mddev->degraded = 1; in rs_check_takeover()
1794 if (mddev->new_level == 0 && in rs_check_takeover()
1795 mddev->raid_disks == 1) in rs_check_takeover()
1799 if (mddev->new_level == 10) in rs_check_takeover()
1805 if (mddev->new_level == 0) in rs_check_takeover()
1809 if ((mddev->new_level == 1 || mddev->new_level == 5) && in rs_check_takeover()
1810 mddev->raid_disks == 2) in rs_check_takeover()
1814 if (__within_range(mddev->new_level, 5, 6) && in rs_check_takeover()
1815 mddev->layout == ALGORITHM_PARITY_N) in rs_check_takeover()
1821 if (mddev->new_level == 0 && in rs_check_takeover()
1822 mddev->layout == ALGORITHM_PARITY_N) in rs_check_takeover()
1826 if (mddev->new_level == 4 && in rs_check_takeover()
1827 mddev->layout == ALGORITHM_PARITY_N) in rs_check_takeover()
1831 if ((mddev->new_level == 1 || mddev->new_level == 4 || mddev->new_level == 10) && in rs_check_takeover()
1832 mddev->raid_disks == 2) in rs_check_takeover()
1836 if (mddev->new_level == 6 && in rs_check_takeover()
1837 ((mddev->layout == ALGORITHM_PARITY_N && mddev->new_layout == ALGORITHM_PARITY_N) || in rs_check_takeover()
1838 … __within_range(mddev->new_layout, ALGORITHM_LEFT_ASYMMETRIC_6, ALGORITHM_RIGHT_SYMMETRIC_6))) in rs_check_takeover()
1844 if (mddev->new_level == 0 && in rs_check_takeover()
1845 mddev->layout == ALGORITHM_PARITY_N) in rs_check_takeover()
1849 if (mddev->new_level == 4 && in rs_check_takeover()
1850 mddev->layout == ALGORITHM_PARITY_N) in rs_check_takeover()
1854 if (mddev->new_level == 5 && in rs_check_takeover()
1855 ((mddev->layout == ALGORITHM_PARITY_N && mddev->new_layout == ALGORITHM_PARITY_N) || in rs_check_takeover()
1856 __within_range(mddev->new_layout, ALGORITHM_LEFT_ASYMMETRIC, ALGORITHM_RIGHT_SYMMETRIC))) in rs_check_takeover()
1886 struct mddev *mddev = &rs->md; in rs_reshape_requested() local
1902 mddev->raid_disks != rs->raid_disks; in rs_reshape_requested()
1907 !__is_raid10_far(mddev->new_layout) && in rs_reshape_requested()
2014 struct mddev *mddev = &rs->md; in rs_check_reshape() local
2016 if (!mddev->pers || !mddev->pers->check_reshape) in rs_check_reshape()
2018 else if (mddev->degraded) in rs_check_reshape()
2044 md_error(rdev->mddev, rdev); in read_disk_sb()
2081 static void super_sync(struct mddev *mddev, struct md_rdev *rdev) in super_sync() argument
2087 struct raid_set *rs = container_of(mddev, struct raid_set, md); in super_sync()
2111 sb->num_devices = cpu_to_le32(mddev->raid_disks); in super_sync()
2114 sb->events = cpu_to_le64(mddev->events); in super_sync()
2117 sb->array_resync_offset = cpu_to_le64(mddev->recovery_cp); in super_sync()
2119 sb->level = cpu_to_le32(mddev->level); in super_sync()
2120 sb->layout = cpu_to_le32(mddev->layout); in super_sync()
2121 sb->stripe_sectors = cpu_to_le32(mddev->chunk_sectors); in super_sync()
2128 sb->new_level = cpu_to_le32(mddev->new_level); in super_sync()
2129 sb->new_layout = cpu_to_le32(mddev->new_layout); in super_sync()
2130 sb->new_stripe_sectors = cpu_to_le32(mddev->new_chunk_sectors); in super_sync()
2132 sb->delta_disks = cpu_to_le32(mddev->delta_disks); in super_sync()
2135 sb->reshape_position = cpu_to_le64(mddev->reshape_position); in super_sync()
2140 if (mddev->delta_disks < 0 || mddev->reshape_backwards) in super_sync()
2147 sb->array_sectors = cpu_to_le64(mddev->array_sectors); in super_sync()
2185 super_sync(rdev->mddev, rdev); in super_load()
2191 set_bit(MD_SB_CHANGE_DEVS, &rdev->mddev->sb_flags); in super_load()
2212 struct mddev *mddev = &rs->md; in super_init_validation() local
2226 mddev->events = events_sb ? : 1; in super_init_validation()
2228 mddev->reshape_position = MaxSector; in super_init_validation()
2230 mddev->raid_disks = le32_to_cpu(sb->num_devices); in super_init_validation()
2231 mddev->level = le32_to_cpu(sb->level); in super_init_validation()
2232 mddev->layout = le32_to_cpu(sb->layout); in super_init_validation()
2233 mddev->chunk_sectors = le32_to_cpu(sb->stripe_sectors); in super_init_validation()
2241 mddev->new_level = le32_to_cpu(sb->new_level); in super_init_validation()
2242 mddev->new_layout = le32_to_cpu(sb->new_layout); in super_init_validation()
2243 mddev->new_chunk_sectors = le32_to_cpu(sb->new_stripe_sectors); in super_init_validation()
2244 mddev->delta_disks = le32_to_cpu(sb->delta_disks); in super_init_validation()
2245 mddev->array_sectors = le64_to_cpu(sb->array_sectors); in super_init_validation()
2254 if (mddev->delta_disks < 0 || in super_init_validation()
2255 (!mddev->delta_disks && (le32_to_cpu(sb->flags) & SB_FLAG_RESHAPE_BACKWARDS))) in super_init_validation()
2256 mddev->reshape_backwards = 1; in super_init_validation()
2258 mddev->reshape_backwards = 0; in super_init_validation()
2260 mddev->reshape_position = le64_to_cpu(sb->reshape_position); in super_init_validation()
2261 rs->raid_type = get_raid_type_by_ll(mddev->level, mddev->layout); in super_init_validation()
2268 struct raid_type *rt_cur = get_raid_type_by_ll(mddev->level, mddev->layout); in super_init_validation()
2269 struct raid_type *rt_new = get_raid_type_by_ll(mddev->new_level, mddev->new_layout); in super_init_validation()
2280 if (mddev->layout != mddev->new_layout) { in super_init_validation()
2286 le32_to_cpu(sb->layout), mddev->new_layout); in super_init_validation()
2288 if (mddev->chunk_sectors != mddev->new_chunk_sectors) in super_init_validation()
2290 mddev->chunk_sectors, mddev->new_chunk_sectors); in super_init_validation()
2293 mddev->raid_disks, mddev->raid_disks + rs->delta_disks); in super_init_validation()
2296 raid10_md_layout_to_format(mddev->layout), in super_init_validation()
2297 raid10_md_layout_to_copies(mddev->layout)); in super_init_validation()
2299 raid10_md_layout_to_format(mddev->new_layout), in super_init_validation()
2300 raid10_md_layout_to_copies(mddev->new_layout)); in super_init_validation()
2309 mddev->recovery_cp = le64_to_cpu(sb->array_resync_offset); in super_init_validation()
2327 rdev_for_each(r, mddev) { in super_init_validation()
2350 set_bit(MD_ARRAY_FIRST_USE, &mddev->flags); in super_init_validation()
2369 (unsigned long long) mddev->recovery_cp); in super_init_validation()
2373 (unsigned long long) mddev->reshape_position); in super_init_validation()
2383 rdev_for_each(r, mddev) { in super_init_validation()
2400 if (rs_is_raid10(rs) && __is_raid10_near(mddev->layout)) { in super_init_validation()
2401 if (mddev->raid_disks % __raid10_near_copies(mddev->layout) || in super_init_validation()
2434 struct mddev *mddev = &rs->md; in super_validate() local
2446 if (!mddev->events && super_init_validation(rs, rdev)) in super_validate()
2461mddev->bitmap_info.offset = (rt_is_raid0(rs->raid_type) || rs->journal_dev.dev) ? 0 : to_sector(40… in super_validate()
2462 mddev->bitmap_info.default_offset = mddev->bitmap_info.offset; in super_validate()
2507 struct mddev *mddev = &rs->md; in analyse_superblocks() local
2510 rdev_for_each(rdev, mddev) { in analyse_superblocks()
2583 rdev_for_each(rdev, mddev) in analyse_superblocks()
2710 struct mddev *mddev = &rs->md; in rs_setup_takeover() local
2712 unsigned int d = mddev->raid_disks = rs->raid_disks; in rs_setup_takeover()
2721 mddev->layout = raid10_format_to_md_layout(rs, ALGORITHM_RAID10_FAR, in rs_setup_takeover()
2725 mddev->layout = raid10_format_to_md_layout(rs, ALGORITHM_RAID10_NEAR, in rs_setup_takeover()
2732 clear_bit(MD_ARRAY_FIRST_USE, &mddev->flags); in rs_setup_takeover()
2733 mddev->recovery_cp = MaxSector; in rs_setup_takeover()
2741 mddev->recovery_cp = rdev->recovery_offset = 0; in rs_setup_takeover()
2743 set_bit(MD_ARRAY_FIRST_USE, &mddev->flags); in rs_setup_takeover()
2756 struct mddev *mddev = &rs->md; in rs_prepare_reshape() local
2759 if (rs->raid_disks != mddev->raid_disks && in rs_prepare_reshape()
2760 __is_raid10_near(mddev->layout) && in rs_prepare_reshape()
2762 rs->raid10_copies != __raid10_near_copies(mddev->layout)) { in rs_prepare_reshape()
2776 mddev->layout = raid10_format_to_md_layout(rs, ALGORITHM_RAID10_NEAR, in rs_prepare_reshape()
2778 mddev->new_layout = mddev->layout; in rs_prepare_reshape()
2789 mddev->degraded = rs->delta_disks < 0 ? -rs->delta_disks : rs->delta_disks; in rs_prepare_reshape()
2793 mddev->raid_disks = rs->raid_disks; in rs_prepare_reshape()
2804 } else if (mddev->raid_disks < rs->raid_disks) in rs_prepare_reshape()
2840 struct mddev *mddev = &rs->md; in rs_setup_reshape() local
2843 mddev->delta_disks = rs->delta_disks; in rs_setup_reshape()
2844 cur_raid_devs = mddev->raid_disks; in rs_setup_reshape()
2847 if (mddev->delta_disks && in rs_setup_reshape()
2848 mddev->layout != mddev->new_layout) { in rs_setup_reshape()
2850 mddev->new_layout = mddev->layout; in rs_setup_reshape()
2889 rdev->sectors = mddev->dev_sectors; in rs_setup_reshape()
2893 mddev->reshape_backwards = 0; /* adding disk(s) -> forward reshape */ in rs_setup_reshape()
2898 mddev->reshape_backwards = 1; /* removing disk(s) -> backward reshape */ in rs_setup_reshape()
2923 mddev->reshape_backwards = rs->dev[0].rdev.data_offset ? 0 : 1; in rs_setup_reshape()
2930 if (!mddev->reshape_backwards) in rs_setup_reshape()
3327 struct mddev *mddev = &rs->md; in raid_map() local
3337 if (unlikely(bio_end_sector(bio) > mddev->array_sectors)) in raid_map()
3340 md_handle_request(mddev, bio); in raid_map()
3364 static enum sync_state decipher_sync_action(struct mddev *mddev, unsigned long recovery) in decipher_sync_action() argument
3372 (!mddev->ro && test_bit(MD_RECOVERY_NEEDED, &recovery)))) { in decipher_sync_action()
3387 if (mddev->reshape_position != MaxSector) in decipher_sync_action()
3425 struct mddev *mddev = &rs->md; in rs_get_progress() local
3436 r = mddev->recovery_cp; in rs_get_progress()
3438 r = mddev->curr_resync_completed; in rs_get_progress()
3490 rdev_for_each(rdev, mddev) in rs_get_progress()
3512 struct mddev *mddev = &rs->md; in raid_status() local
3513 struct r5conf *conf = rs_is_raid456(rs) ? mddev->private : NULL; in raid_status()
3526 rt = get_raid_type_by_ll(mddev->new_level, mddev->new_layout); in raid_status()
3530 DMEMIT("%s %d ", rt->name, mddev->raid_disks); in raid_status()
3536 mddev->resync_max_sectors : mddev->dev_sectors; in raid_status()
3538 state = decipher_sync_action(mddev, recovery); in raid_status()
3540 resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ? in raid_status()
3541 atomic64_read(&mddev->resync_mismatches) : 0; in raid_status()
3618 DMEMIT("%s %u %u", rs->raid_type->name, raid_param_cnt, mddev->new_chunk_sectors); in raid_status()
3629 mddev->bitmap_info.daemon_sleep); in raid_status()
3632 mddev->sync_speed_min); in raid_status()
3635 mddev->sync_speed_max); in raid_status()
3643 mddev->bitmap_info.max_write_behind); in raid_status()
3649 (unsigned long long) to_sector(mddev->bitmap_info.chunksize)); in raid_status()
3652 raid10_md_layout_to_copies(mddev->layout)); in raid_status()
3655 raid10_md_layout_to_format(mddev->layout)); in raid_status()
3658 max(rs->delta_disks, mddev->delta_disks)); in raid_status()
3675 rt = get_raid_type_by_ll(mddev->new_level, mddev->new_layout); in raid_status()
3680 DMEMIT(",raid_type=%s,raid_disks=%d", rt->name, mddev->raid_disks); in raid_status()
3685 state = decipher_sync_action(mddev, recovery); in raid_status()
3718 struct mddev *mddev = &rs->md; in raid_message() local
3720 if (!mddev->pers || !mddev->pers->sync_request) in raid_message()
3724 set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); in raid_message()
3726 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); in raid_message()
3729 if (mddev->sync_thread) { in raid_message()
3730 set_bit(MD_RECOVERY_INTR, &mddev->recovery); in raid_message()
3731 md_unregister_thread(&mddev->sync_thread); in raid_message()
3732 md_reap_sync_thread(mddev); in raid_message()
3734 } else if (decipher_sync_action(mddev, mddev->recovery) != st_idle) in raid_message()
3739 set_bit(MD_RECOVERY_RECOVER, &mddev->recovery); in raid_message()
3742 set_bit(MD_RECOVERY_CHECK, &mddev->recovery); in raid_message()
3743 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); in raid_message()
3744 set_bit(MD_RECOVERY_SYNC, &mddev->recovery); in raid_message()
3746 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); in raid_message()
3747 set_bit(MD_RECOVERY_SYNC, &mddev->recovery); in raid_message()
3751 if (mddev->ro == 2) { in raid_message()
3755 mddev->ro = 0; in raid_message()
3756 if (!mddev->suspended && mddev->sync_thread) in raid_message()
3757 md_wakeup_thread(mddev->sync_thread); in raid_message()
3759 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); in raid_message()
3760 if (!mddev->suspended && mddev->thread) in raid_message()
3761 md_wakeup_thread(mddev->thread); in raid_message()
3815 struct mddev *mddev = &rs->md; in attempt_restore_of_faulty_devices() local
3819 if (!mddev->pers || !mddev->pers->hot_add_disk || !mddev->pers->hot_remove_disk) in attempt_restore_of_faulty_devices()
3848 if (mddev->pers->hot_remove_disk(mddev, r)) { in attempt_restore_of_faulty_devices()
3859 if (mddev->pers->hot_add_disk(mddev, r)) { in attempt_restore_of_faulty_devices()
3909 struct mddev *mddev = &rs->md; in rs_update_sbs() local
3910 int ro = mddev->ro; in rs_update_sbs()
3912 set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags); in rs_update_sbs()
3913 mddev->ro = 0; in rs_update_sbs()
3914 md_update_sb(mddev, 1); in rs_update_sbs()
3915 mddev->ro = ro; in rs_update_sbs()
3928 struct mddev *mddev = &rs->md; in rs_start_reshape() local
3929 struct md_personality *pers = mddev->pers; in rs_start_reshape()
3932 set_bit(MD_RECOVERY_WAIT, &mddev->recovery); in rs_start_reshape()
3943 r = pers->check_reshape(mddev); in rs_start_reshape()
3954 r = pers->start_reshape(mddev); in rs_start_reshape()
3975 struct mddev *mddev = &rs->md; in raid_preresume() local
3997 mddev->array_sectors = rs->array_sectors; in raid_preresume()
3998 mddev->dev_sectors = rs->dev_sectors; in raid_preresume()
4004 if (test_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags) && mddev->bitmap && in raid_preresume()
4007 mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)))) { in raid_preresume()
4008 int chunksize = to_bytes(rs->requested_bitmap_chunk_sectors) ?: mddev->bitmap_info.chunksize; in raid_preresume()
4010 r = md_bitmap_resize(mddev->bitmap, mddev->dev_sectors, chunksize, 0); in raid_preresume()
4017 set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); in raid_preresume()
4018 if (mddev->recovery_cp && mddev->recovery_cp < MaxSector) { in raid_preresume()
4019 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); in raid_preresume()
4020 mddev->resync_min = mddev->recovery_cp; in raid_preresume()
4022 mddev->resync_max_sectors = mddev->dev_sectors; in raid_preresume()
4029 mddev_lock_nointr(mddev); in raid_preresume()
4031 mddev_unlock(mddev); in raid_preresume()
4043 struct mddev *mddev = &rs->md; in raid_resume() local
4056 if (mddev->delta_disks < 0) in raid_resume()
4059 mddev_lock_nointr(mddev); in raid_resume()
4060 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); in raid_resume()
4061 mddev->ro = 0; in raid_resume()
4062 mddev->in_sync = 0; in raid_resume()
4063 mddev_resume(mddev); in raid_resume()
4064 mddev_unlock(mddev); in raid_resume()