Lines Matching refs:mddev
84 struct mddev *mddev = rdev->mddev; in wait_for_serialization() local
89 if (WARN_ON(!mddev->serial_info_pool)) in wait_for_serialization()
91 si = mempool_alloc(mddev->serial_info_pool, GFP_NOIO); in wait_for_serialization()
101 struct mddev *mddev = rdev->mddev; in remove_serial() local
110 mempool_free(si, mddev->serial_info_pool); in remove_serial()
180 if (test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) in r1buf_pool_alloc()
255 struct r1conf *conf = r1_bio->mddev->private; in free_r1bio()
263 struct r1conf *conf = r1_bio->mddev->private; in put_buf()
270 rdev_dec_pending(conf->mirrors[i].rdev, r1_bio->mddev); in put_buf()
281 struct mddev *mddev = r1_bio->mddev; in reschedule_retry() local
282 struct r1conf *conf = mddev->private; in reschedule_retry()
292 md_wakeup_thread(mddev->thread); in reschedule_retry()
315 struct r1conf *conf = r1_bio->mddev->private; in raid_end_bio_io()
340 struct r1conf *conf = r1_bio->mddev->private; in update_head_pos()
352 struct r1conf *conf = r1_bio->mddev->private; in find_bio_disk()
369 struct r1conf *conf = r1_bio->mddev->private; in raid1_end_read_request()
391 if (r1_bio->mddev->degraded == conf->raid_disks || in raid1_end_read_request()
392 (r1_bio->mddev->degraded == conf->raid_disks-1 && in raid1_end_read_request()
400 rdev_dec_pending(rdev, conf->mddev); in raid1_end_read_request()
406 mdname(conf->mddev), in raid1_end_read_request()
424 md_bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector, in close_write()
428 md_write_end(r1_bio->mddev); in close_write()
451 struct r1conf *conf = r1_bio->mddev->private; in raid1_end_write_request()
468 conf->mddev->recovery); in raid1_end_write_request()
474 md_error(r1_bio->mddev, rdev); in raid1_end_write_request()
551 } else if (rdev->mddev->serialize_policy) in raid1_end_write_request()
554 rdev_dec_pending(rdev, conf->mddev); in raid1_end_write_request()
631 if ((conf->mddev->recovery_cp < this_sector + sectors) || in read_balance()
632 (mddev_is_clustered(conf->mddev) && in read_balance()
633 md_cluster_ops->area_resyncing(conf->mddev, READ, this_sector, in read_balance()
797 md_bitmap_unplug(conf->mddev->bitmap); in flush_bio_list()
907 test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery), in raise_barrier()
910 if (test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { in raise_barrier()
1106 raid1_log(conf->mddev, "wait freeze"); in freeze_array()
1132 &r1_bio->mddev->bio_set); in alloc_behind_master_bio()
1174 struct mddev *mddev = plug->cb.data; in raid1_unplug() local
1175 struct r1conf *conf = mddev->private; in raid1_unplug()
1183 md_wakeup_thread(mddev->thread); in raid1_unplug()
1194 static void init_r1bio(struct r1bio *r1_bio, struct mddev *mddev, struct bio *bio) in init_r1bio() argument
1199 r1_bio->mddev = mddev; in init_r1bio()
1204 alloc_r1bio(struct mddev *mddev, struct bio *bio) in alloc_r1bio() argument
1206 struct r1conf *conf = mddev->private; in alloc_r1bio()
1212 init_r1bio(r1_bio, mddev, bio); in alloc_r1bio()
1216 static void raid1_read_request(struct mddev *mddev, struct bio *bio, in raid1_read_request() argument
1219 struct r1conf *conf = mddev->private; in raid1_read_request()
1222 struct bitmap *bitmap = mddev->bitmap; in raid1_read_request()
1260 r1_bio = alloc_r1bio(mddev, bio); in raid1_read_request()
1262 init_r1bio(r1_bio, mddev, bio); in raid1_read_request()
1275 mdname(mddev), in raid1_read_request()
1286 mdname(mddev), in raid1_read_request()
1296 raid1_log(mddev, "wait behind writes"); in raid1_read_request()
1317 &mddev->bio_set); in raid1_read_request()
1330 if (mddev->gendisk) in raid1_read_request()
1331 trace_block_bio_remap(read_bio, disk_devt(mddev->gendisk), in raid1_read_request()
1337 static void raid1_write_request(struct mddev *mddev, struct bio *bio, in raid1_write_request() argument
1340 struct r1conf *conf = mddev->private; in raid1_write_request()
1343 struct bitmap *bitmap = mddev->bitmap; in raid1_write_request()
1352 if (mddev_is_clustered(mddev) && in raid1_write_request()
1353 md_cluster_ops->area_resyncing(mddev, WRITE, in raid1_write_request()
1364 if (!md_cluster_ops->area_resyncing(mddev, WRITE, in raid1_write_request()
1384 r1_bio = alloc_r1bio(mddev, bio); in raid1_write_request()
1449 rdev_dec_pending(rdev, mddev); in raid1_write_request()
1478 rdev_dec_pending(conf->mirrors[j].rdev, mddev); in raid1_write_request()
1486 raid1_log(mddev, "wait rdev %d blocked", blocked_rdev->raid_disk); in raid1_write_request()
1487 md_wait_for_blocked_rdev(blocked_rdev, mddev); in raid1_write_request()
1532 < mddev->bitmap_info.max_write_behind) && in raid1_write_request()
1545 GFP_NOIO, &mddev->bio_set); in raid1_write_request()
1552 &mddev->bio_set); in raid1_write_request()
1554 if (mddev->serialize_policy) in raid1_write_request()
1565 conf->raid_disks - mddev->degraded > 1) in raid1_write_request()
1571 if (mddev->gendisk) in raid1_write_request()
1572 trace_block_bio_remap(mbio, disk_devt(mddev->gendisk), in raid1_write_request()
1577 cb = blk_check_plugged(raid1_unplug, mddev, sizeof(*plug)); in raid1_write_request()
1588 md_wakeup_thread(mddev->thread); in raid1_write_request()
1598 static bool raid1_make_request(struct mddev *mddev, struct bio *bio) in raid1_make_request() argument
1603 && md_flush_request(mddev, bio)) in raid1_make_request()
1617 raid1_read_request(mddev, bio, sectors, NULL); in raid1_make_request()
1619 if (!md_write_start(mddev,bio)) in raid1_make_request()
1621 raid1_write_request(mddev, bio, sectors); in raid1_make_request()
1626 static void raid1_status(struct seq_file *seq, struct mddev *mddev) in raid1_status() argument
1628 struct r1conf *conf = mddev->private; in raid1_status()
1632 conf->raid_disks - mddev->degraded); in raid1_status()
1659 static void raid1_error(struct mddev *mddev, struct md_rdev *rdev) in raid1_error() argument
1661 struct r1conf *conf = mddev->private; in raid1_error()
1667 (conf->raid_disks - mddev->degraded) == 1) { in raid1_error()
1668 set_bit(MD_BROKEN, &mddev->flags); in raid1_error()
1670 if (!mddev->fail_last_dev) { in raid1_error()
1671 conf->recovery_disabled = mddev->recovery_disabled; in raid1_error()
1678 mddev->degraded++; in raid1_error()
1684 set_bit(MD_RECOVERY_INTR, &mddev->recovery); in raid1_error()
1685 set_mask_bits(&mddev->sb_flags, 0, in raid1_error()
1689 mdname(mddev), rdev->bdev, in raid1_error()
1690 mdname(mddev), conf->raid_disks - mddev->degraded); in raid1_error()
1702 pr_debug(" --- wd:%d rd:%d\n", conf->raid_disks - conf->mddev->degraded, in print_conf()
1729 static int raid1_spare_active(struct mddev *mddev) in raid1_spare_active() argument
1732 struct r1conf *conf = mddev->private; in raid1_spare_active()
1774 mddev->degraded -= count; in raid1_spare_active()
1781 static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev) in raid1_add_disk() argument
1783 struct r1conf *conf = mddev->private; in raid1_add_disk()
1790 if (mddev->recovery_disabled == conf->recovery_disabled) in raid1_add_disk()
1793 if (md_integrity_add_rdev(rdev, mddev)) in raid1_add_disk()
1812 if (mddev->gendisk) in raid1_add_disk()
1813 disk_stack_limits(mddev->gendisk, rdev->bdev, in raid1_add_disk()
1843 static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev) in raid1_remove_disk() argument
1845 struct r1conf *conf = mddev->private; in raid1_remove_disk()
1864 mddev->recovery_disabled != conf->recovery_disabled && in raid1_remove_disk()
1865 mddev->degraded < conf->raid_disks) { in raid1_remove_disk()
1905 err = md_integrity_register(mddev); in raid1_remove_disk()
1931 static void abort_sync_write(struct mddev *mddev, struct r1bio *r1_bio) in abort_sync_write() argument
1939 md_bitmap_end_sync(mddev->bitmap, s, &sync_blocks, 1); in abort_sync_write()
1948 struct mddev *mddev = r1_bio->mddev; in put_sync_write_buf() local
1956 md_done_sync(mddev, s, uptodate); in put_sync_write_buf()
1965 struct mddev *mddev = r1_bio->mddev; in end_sync_write() local
1966 struct r1conf *conf = mddev->private; in end_sync_write()
1972 abort_sync_write(mddev, r1_bio); in end_sync_write()
1976 mddev->recovery); in end_sync_write()
2001 rdev->mddev->recovery); in r1_sync_page_io()
2005 md_error(rdev->mddev, rdev); in r1_sync_page_io()
2022 struct mddev *mddev = r1_bio->mddev; in fix_sync_read_error() local
2023 struct r1conf *conf = mddev->private; in fix_sync_read_error()
2035 md_error(mddev, rdev); in fix_sync_read_error()
2078 mdname(mddev), bio->bi_bdev, in fix_sync_read_error()
2089 mddev->recovery_disabled; in fix_sync_read_error()
2090 set_bit(MD_RECOVERY_INTR, &mddev->recovery); in fix_sync_read_error()
2091 md_done_sync(mddev, r1_bio->sectors, 0); in fix_sync_read_error()
2115 rdev_dec_pending(rdev, mddev); in fix_sync_read_error()
2149 struct mddev *mddev = r1_bio->mddev; in process_checks() local
2150 struct r1conf *conf = mddev->private; in process_checks()
2180 rdev_dec_pending(conf->mirrors[primary].rdev, mddev); in process_checks()
2213 atomic64_add(r1_bio->sectors, &mddev->resync_mismatches); in process_checks()
2214 if (j < 0 || (test_bit(MD_RECOVERY_CHECK, &mddev->recovery) in process_checks()
2218 rdev_dec_pending(conf->mirrors[i].rdev, mddev); in process_checks()
2226 static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio) in sync_request_write() argument
2228 struct r1conf *conf = mddev->private; in sync_request_write()
2238 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) in sync_request_write()
2250 !test_bit(MD_RECOVERY_SYNC, &mddev->recovery)))) in sync_request_write()
2253 abort_sync_write(mddev, r1_bio); in sync_request_write()
2282 struct mddev *mddev = conf->mddev; in fix_read_error() local
2310 rdev_dec_pending(rdev, mddev); in fix_read_error()
2324 md_error(mddev, rdev); in fix_read_error()
2341 rdev_dec_pending(rdev, mddev); in fix_read_error()
2360 mdname(mddev), s, in fix_read_error()
2365 rdev_dec_pending(rdev, mddev); in fix_read_error()
2376 struct mddev *mddev = r1_bio->mddev; in narrow_write_error() local
2377 struct r1conf *conf = mddev->private; in narrow_write_error()
2416 GFP_NOIO, &mddev->bio_set); in narrow_write_error()
2419 GFP_NOIO, &mddev->bio_set); in narrow_write_error()
2459 md_error(conf->mddev, rdev); in handle_sync_write_finished()
2463 md_done_sync(conf->mddev, s, 1); in handle_sync_write_finished()
2477 rdev_dec_pending(rdev, conf->mddev); in handle_write_finished()
2485 md_error(conf->mddev, in handle_write_finished()
2491 conf->mddev); in handle_write_finished()
2504 md_wakeup_thread(conf->mddev->thread); in handle_write_finished()
2514 struct mddev *mddev = conf->mddev; in handle_read_error() local
2533 if (mddev->ro == 0 in handle_read_error()
2539 } else if (mddev->ro == 0 && test_bit(FailFast, &rdev->flags)) { in handle_read_error()
2540 md_error(mddev, rdev); in handle_read_error()
2545 rdev_dec_pending(rdev, conf->mddev); in handle_read_error()
2551 raid1_read_request(mddev, bio, r1_bio->sectors, r1_bio); in handle_read_error()
2556 struct mddev *mddev = thread->mddev; in raid1d() local
2559 struct r1conf *conf = mddev->private; in raid1d()
2564 md_check_recovery(mddev); in raid1d()
2567 !test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags)) { in raid1d()
2570 if (!test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags)) in raid1d()
2579 if (mddev->degraded) in raid1d()
2603 mddev = r1_bio->mddev; in raid1d()
2604 conf = mddev->private; in raid1d()
2610 sync_request_write(mddev, r1_bio); in raid1d()
2620 if (mddev->sb_flags & ~(1<<MD_SB_CHANGE_PENDING)) in raid1d()
2621 md_check_recovery(mddev); in raid1d()
2664 static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr, in raid1_sync_request() argument
2667 struct r1conf *conf = mddev->private; in raid1_sync_request()
2686 max_sector = mddev->dev_sectors; in raid1_sync_request()
2693 if (mddev->curr_resync < max_sector) /* aborted */ in raid1_sync_request()
2694 md_bitmap_end_sync(mddev->bitmap, mddev->curr_resync, in raid1_sync_request()
2699 md_bitmap_close_sync(mddev->bitmap); in raid1_sync_request()
2702 if (mddev_is_clustered(mddev)) { in raid1_sync_request()
2709 if (mddev->bitmap == NULL && in raid1_sync_request()
2710 mddev->recovery_cp == MaxSector && in raid1_sync_request()
2711 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) && in raid1_sync_request()
2719 if (!md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) && in raid1_sync_request()
2720 !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { in raid1_sync_request()
2737 md_bitmap_cond_end_sync(mddev->bitmap, sector_nr, in raid1_sync_request()
2738 mddev_is_clustered(mddev) && (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high)); in raid1_sync_request()
2756 r1_bio->mddev = mddev; in raid1_sync_request()
2804 test_bit(MD_RECOVERY_SYNC, &mddev->recovery) && in raid1_sync_request()
2805 !test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) { in raid1_sync_request()
2842 set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags); in raid1_sync_request()
2852 conf->recovery_disabled = mddev->recovery_disabled; in raid1_sync_request()
2853 set_bit(MD_RECOVERY_INTR, &mddev->recovery); in raid1_sync_request()
2865 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) && read_targets > 0) in raid1_sync_request()
2882 if (max_sector > mddev->resync_max) in raid1_sync_request()
2883 max_sector = mddev->resync_max; /* Don't do IO beyond here */ in raid1_sync_request()
2896 if (!md_bitmap_start_sync(mddev->bitmap, sector_nr, in raid1_sync_request()
2899 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) in raid1_sync_request()
2927 if (mddev_is_clustered(mddev) && in raid1_sync_request()
2929 conf->cluster_sync_low = mddev->curr_resync_completed; in raid1_sync_request()
2932 md_cluster_ops->resync_info_update(mddev, in raid1_sync_request()
2940 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) { in raid1_sync_request()
2963 static sector_t raid1_size(struct mddev *mddev, sector_t sectors, int raid_disks) in raid1_size() argument
2968 return mddev->dev_sectors; in raid1_size()
2971 static struct r1conf *setup_conf(struct mddev *mddev) in setup_conf() argument
3004 mddev->raid_disks, 2), in setup_conf()
3016 conf->poolinfo->raid_disks = mddev->raid_disks * 2; in setup_conf()
3026 conf->poolinfo->mddev = mddev; in setup_conf()
3030 rdev_for_each(rdev, mddev) { in setup_conf()
3032 if (disk_idx >= mddev->raid_disks in setup_conf()
3036 disk = conf->mirrors + mddev->raid_disks + disk_idx; in setup_conf()
3046 conf->raid_disks = mddev->raid_disks; in setup_conf()
3047 conf->mddev = mddev; in setup_conf()
3055 conf->recovery_disabled = mddev->recovery_disabled - 1; in setup_conf()
3087 conf->thread = md_register_thread(raid1d, mddev, "raid1"); in setup_conf()
3109 static void raid1_free(struct mddev *mddev, void *priv);
3110 static int raid1_run(struct mddev *mddev) in raid1_run() argument
3117 if (mddev->level != 1) { in raid1_run()
3119 mdname(mddev), mddev->level); in raid1_run()
3122 if (mddev->reshape_position != MaxSector) { in raid1_run()
3124 mdname(mddev)); in raid1_run()
3127 if (mddev_init_writes_pending(mddev) < 0) in raid1_run()
3134 if (mddev->private == NULL) in raid1_run()
3135 conf = setup_conf(mddev); in raid1_run()
3137 conf = mddev->private; in raid1_run()
3142 if (mddev->queue) in raid1_run()
3143 blk_queue_max_write_zeroes_sectors(mddev->queue, 0); in raid1_run()
3145 rdev_for_each(rdev, mddev) { in raid1_run()
3146 if (!mddev->gendisk) in raid1_run()
3148 disk_stack_limits(mddev->gendisk, rdev->bdev, in raid1_run()
3152 mddev->degraded = 0; in raid1_run()
3157 mddev->degraded++; in raid1_run()
3161 if (conf->raid_disks - mddev->degraded < 1) { in raid1_run()
3167 if (conf->raid_disks - mddev->degraded == 1) in raid1_run()
3168 mddev->recovery_cp = MaxSector; in raid1_run()
3170 if (mddev->recovery_cp != MaxSector) in raid1_run()
3172 mdname(mddev)); in raid1_run()
3174 mdname(mddev), mddev->raid_disks - mddev->degraded, in raid1_run()
3175 mddev->raid_disks); in raid1_run()
3180 mddev->thread = conf->thread; in raid1_run()
3182 mddev->private = conf; in raid1_run()
3183 set_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); in raid1_run()
3185 md_set_array_sectors(mddev, raid1_size(mddev, 0, 0)); in raid1_run()
3187 ret = md_integrity_register(mddev); in raid1_run()
3189 md_unregister_thread(&mddev->thread); in raid1_run()
3195 raid1_free(mddev, conf); in raid1_run()
3199 static void raid1_free(struct mddev *mddev, void *priv) in raid1_free() argument
3215 static int raid1_resize(struct mddev *mddev, sector_t sectors) in raid1_resize() argument
3224 sector_t newsize = raid1_size(mddev, sectors, 0); in raid1_resize()
3225 if (mddev->external_size && in raid1_resize()
3226 mddev->array_sectors > newsize) in raid1_resize()
3228 if (mddev->bitmap) { in raid1_resize()
3229 int ret = md_bitmap_resize(mddev->bitmap, newsize, 0, 0); in raid1_resize()
3233 md_set_array_sectors(mddev, newsize); in raid1_resize()
3234 if (sectors > mddev->dev_sectors && in raid1_resize()
3235 mddev->recovery_cp > mddev->dev_sectors) { in raid1_resize()
3236 mddev->recovery_cp = mddev->dev_sectors; in raid1_resize()
3237 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); in raid1_resize()
3239 mddev->dev_sectors = sectors; in raid1_resize()
3240 mddev->resync_max_sectors = sectors; in raid1_resize()
3244 static int raid1_reshape(struct mddev *mddev) in raid1_reshape() argument
3260 struct r1conf *conf = mddev->private; in raid1_reshape()
3270 if (mddev->chunk_sectors != mddev->new_chunk_sectors || in raid1_reshape()
3271 mddev->layout != mddev->new_layout || in raid1_reshape()
3272 mddev->level != mddev->new_level) { in raid1_reshape()
3273 mddev->new_chunk_sectors = mddev->chunk_sectors; in raid1_reshape()
3274 mddev->new_layout = mddev->layout; in raid1_reshape()
3275 mddev->new_level = mddev->level; in raid1_reshape()
3279 if (!mddev_is_clustered(mddev)) in raid1_reshape()
3280 md_allow_write(mddev); in raid1_reshape()
3282 raid_disks = mddev->raid_disks + mddev->delta_disks; in raid1_reshape()
3296 newpoolinfo->mddev = mddev; in raid1_reshape()
3323 sysfs_unlink_rdev(mddev, rdev); in raid1_reshape()
3325 sysfs_unlink_rdev(mddev, rdev); in raid1_reshape()
3326 if (sysfs_link_rdev(mddev, rdev)) in raid1_reshape()
3328 mdname(mddev), rdev->raid_disk); in raid1_reshape()
3339 mddev->degraded += (raid_disks - conf->raid_disks); in raid1_reshape()
3341 conf->raid_disks = mddev->raid_disks = raid_disks; in raid1_reshape()
3342 mddev->delta_disks = 0; in raid1_reshape()
3346 set_bit(MD_RECOVERY_RECOVER, &mddev->recovery); in raid1_reshape()
3347 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); in raid1_reshape()
3348 md_wakeup_thread(mddev->thread); in raid1_reshape()
3354 static void raid1_quiesce(struct mddev *mddev, int quiesce) in raid1_quiesce() argument
3356 struct r1conf *conf = mddev->private; in raid1_quiesce()
3364 static void *raid1_takeover(struct mddev *mddev) in raid1_takeover() argument
3369 if (mddev->level == 5 && mddev->raid_disks == 2) { in raid1_takeover()
3371 mddev->new_level = 1; in raid1_takeover()
3372 mddev->new_layout = 0; in raid1_takeover()
3373 mddev->new_chunk_sectors = 0; in raid1_takeover()
3374 conf = setup_conf(mddev); in raid1_takeover()
3378 mddev_clear_unsupported_flags(mddev, in raid1_takeover()