Lines Matching refs:mddev
35 static void dump_zones(struct mddev *mddev) in dump_zones() argument
40 struct r0conf *conf = mddev->private; in dump_zones()
43 mdname(mddev), in dump_zones()
63 static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) in create_strip_zones() argument
76 rdev_for_each(rdev1, mddev) { in create_strip_zones()
78 mdname(mddev), in create_strip_zones()
84 sector_div(sectors, mddev->chunk_sectors); in create_strip_zones()
85 rdev1->sectors = sectors * mddev->chunk_sectors; in create_strip_zones()
90 rdev_for_each(rdev2, mddev) { in create_strip_zones()
93 mdname(mddev), in create_strip_zones()
100 mdname(mddev)); in create_strip_zones()
109 mdname(mddev)); in create_strip_zones()
114 mdname(mddev)); in create_strip_zones()
118 mdname(mddev)); in create_strip_zones()
121 mdname(mddev), conf->nr_strip_zones); in create_strip_zones()
125 mdname(mddev), conf->nr_strip_zones); in create_strip_zones()
131 if ((mddev->chunk_sectors << 9) % blksize) { in create_strip_zones()
133 mdname(mddev), in create_strip_zones()
134 mddev->chunk_sectors << 9, blksize); in create_strip_zones()
147 mddev->raid_disks), in create_strip_zones()
160 rdev_for_each(rdev1, mddev) { in create_strip_zones()
163 if (mddev->level == 10) { in create_strip_zones()
169 if (mddev->level == 1) { in create_strip_zones()
179 mdname(mddev)); in create_strip_zones()
182 if (j >= mddev->raid_disks) { in create_strip_zones()
184 mdname(mddev), j); in create_strip_zones()
189 mdname(mddev), j); in create_strip_zones()
198 if (cnt != mddev->raid_disks) { in create_strip_zones()
200 mdname(mddev), cnt, mddev->raid_disks); in create_strip_zones()
214 dev = conf->devlist + i * mddev->raid_disks; in create_strip_zones()
216 pr_debug("md/raid0:%s: zone %d\n", mdname(mddev), i); in create_strip_zones()
225 mdname(mddev), in create_strip_zones()
231 mdname(mddev), in create_strip_zones()
238 mdname(mddev), in create_strip_zones()
246 mdname(mddev), in create_strip_zones()
253 mdname(mddev), in create_strip_zones()
259 } else if (mddev->layout == RAID0_ORIG_LAYOUT || in create_strip_zones()
260 mddev->layout == RAID0_ALT_MULTIZONE_LAYOUT) { in create_strip_zones()
261 conf->layout = mddev->layout; in create_strip_zones()
267 mdname(mddev)); in create_strip_zones()
273 pr_debug("md/raid0:%s: done.\n", mdname(mddev)); in create_strip_zones()
308 static struct md_rdev *map_sector(struct mddev *mddev, struct strip_zone *zone, in map_sector() argument
313 struct r0conf *conf = mddev->private; in map_sector()
315 unsigned int chunk_sects = mddev->chunk_sectors; in map_sector()
341 static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks) in raid0_size() argument
349 rdev_for_each(rdev, mddev) in raid0_size()
351 ~(sector_t)(mddev->chunk_sectors-1)); in raid0_size()
356 static void free_conf(struct mddev *mddev, struct r0conf *conf) in free_conf() argument
363 static void raid0_free(struct mddev *mddev, void *priv) in raid0_free() argument
367 free_conf(mddev, conf); in raid0_free()
368 acct_bioset_exit(mddev); in raid0_free()
371 static int raid0_run(struct mddev *mddev) in raid0_run() argument
376 if (mddev->chunk_sectors == 0) { in raid0_run()
377 pr_warn("md/raid0:%s: chunk size must be set.\n", mdname(mddev)); in raid0_run()
380 if (md_check_no_bitmap(mddev)) in raid0_run()
383 if (acct_bioset_init(mddev)) { in raid0_run()
384 pr_err("md/raid0:%s: alloc acct bioset failed.\n", mdname(mddev)); in raid0_run()
389 if (mddev->private == NULL) { in raid0_run()
390 ret = create_strip_zones(mddev, &conf); in raid0_run()
393 mddev->private = conf; in raid0_run()
395 conf = mddev->private; in raid0_run()
396 if (mddev->queue) { in raid0_run()
399 blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors); in raid0_run()
400 blk_queue_max_write_zeroes_sectors(mddev->queue, mddev->chunk_sectors); in raid0_run()
401 blk_queue_max_discard_sectors(mddev->queue, UINT_MAX); in raid0_run()
403 blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9); in raid0_run()
404 blk_queue_io_opt(mddev->queue, in raid0_run()
405 (mddev->chunk_sectors << 9) * mddev->raid_disks); in raid0_run()
407 rdev_for_each(rdev, mddev) { in raid0_run()
408 disk_stack_limits(mddev->gendisk, rdev->bdev, in raid0_run()
414 md_set_array_sectors(mddev, raid0_size(mddev, 0, 0)); in raid0_run()
417 mdname(mddev), in raid0_run()
418 (unsigned long long)mddev->array_sectors); in raid0_run()
420 dump_zones(mddev); in raid0_run()
422 ret = md_integrity_register(mddev); in raid0_run()
429 free_conf(mddev, conf); in raid0_run()
431 acct_bioset_exit(mddev); in raid0_run()
435 static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) in raid0_handle_discard() argument
437 struct r0conf *conf = mddev->private; in raid0_handle_discard()
454 &mddev->bio_set); in raid0_handle_discard()
466 stripe_size = zone->nb_dev * mddev->chunk_sectors; in raid0_handle_discard()
474 mddev->chunk_sectors; in raid0_handle_discard()
476 mddev->chunk_sectors) + in raid0_handle_discard()
477 first_stripe_index * mddev->chunk_sectors; in raid0_handle_discard()
479 mddev->chunk_sectors; in raid0_handle_discard()
481 mddev->chunk_sectors) + in raid0_handle_discard()
482 last_stripe_index * mddev->chunk_sectors; in raid0_handle_discard()
490 mddev->chunk_sectors; in raid0_handle_discard()
492 dev_start = first_stripe_index * mddev->chunk_sectors; in raid0_handle_discard()
497 dev_end = (last_stripe_index + 1) * mddev->chunk_sectors; in raid0_handle_discard()
499 dev_end = last_stripe_index * mddev->chunk_sectors; in raid0_handle_discard()
508 md_submit_discard_bio(mddev, rdev, bio, in raid0_handle_discard()
515 static bool raid0_make_request(struct mddev *mddev, struct bio *bio) in raid0_make_request() argument
517 struct r0conf *conf = mddev->private; in raid0_make_request()
527 && md_flush_request(mddev, bio)) in raid0_make_request()
531 raid0_handle_discard(mddev, bio); in raid0_make_request()
537 chunk_sects = mddev->chunk_sectors; in raid0_make_request()
549 &mddev->bio_set); in raid0_make_request()
555 if (bio->bi_pool != &mddev->bio_set) in raid0_make_request()
556 md_account_bio(mddev, &bio); in raid0_make_request()
559 zone = find_zone(mddev->private, §or); in raid0_make_request()
562 tmp_dev = map_sector(mddev, zone, orig_sector, §or); in raid0_make_request()
565 tmp_dev = map_sector(mddev, zone, sector, §or); in raid0_make_request()
568 WARN(1, "md/raid0:%s: Invalid layout\n", mdname(mddev)); in raid0_make_request()
582 if (mddev->gendisk) in raid0_make_request()
583 trace_block_bio_remap(bio, disk_devt(mddev->gendisk), in raid0_make_request()
585 mddev_check_write_zeroes(mddev, bio); in raid0_make_request()
590 static void raid0_status(struct seq_file *seq, struct mddev *mddev) in raid0_status() argument
592 seq_printf(seq, " %dk chunks", mddev->chunk_sectors / 2); in raid0_status()
596 static void *raid0_takeover_raid45(struct mddev *mddev) in raid0_takeover_raid45() argument
601 if (mddev->degraded != 1) { in raid0_takeover_raid45()
603 mdname(mddev), in raid0_takeover_raid45()
604 mddev->degraded); in raid0_takeover_raid45()
608 rdev_for_each(rdev, mddev) { in raid0_takeover_raid45()
610 if (rdev->raid_disk == mddev->raid_disks-1) { in raid0_takeover_raid45()
612 mdname(mddev)); in raid0_takeover_raid45()
615 rdev->sectors = mddev->dev_sectors; in raid0_takeover_raid45()
619 mddev->new_level = 0; in raid0_takeover_raid45()
620 mddev->new_layout = 0; in raid0_takeover_raid45()
621 mddev->new_chunk_sectors = mddev->chunk_sectors; in raid0_takeover_raid45()
622 mddev->raid_disks--; in raid0_takeover_raid45()
623 mddev->delta_disks = -1; in raid0_takeover_raid45()
625 mddev->recovery_cp = MaxSector; in raid0_takeover_raid45()
626 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); in raid0_takeover_raid45()
628 create_strip_zones(mddev, &priv_conf); in raid0_takeover_raid45()
633 static void *raid0_takeover_raid10(struct mddev *mddev) in raid0_takeover_raid10() argument
643 if (mddev->layout != ((1 << 8) + 2)) { in raid0_takeover_raid10()
645 mdname(mddev), in raid0_takeover_raid10()
646 mddev->layout); in raid0_takeover_raid10()
649 if (mddev->raid_disks & 1) { in raid0_takeover_raid10()
651 mdname(mddev)); in raid0_takeover_raid10()
654 if (mddev->degraded != (mddev->raid_disks>>1)) { in raid0_takeover_raid10()
656 mdname(mddev)); in raid0_takeover_raid10()
661 mddev->new_level = 0; in raid0_takeover_raid10()
662 mddev->new_layout = 0; in raid0_takeover_raid10()
663 mddev->new_chunk_sectors = mddev->chunk_sectors; in raid0_takeover_raid10()
664 mddev->delta_disks = - mddev->raid_disks / 2; in raid0_takeover_raid10()
665 mddev->raid_disks += mddev->delta_disks; in raid0_takeover_raid10()
666 mddev->degraded = 0; in raid0_takeover_raid10()
668 mddev->recovery_cp = MaxSector; in raid0_takeover_raid10()
669 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); in raid0_takeover_raid10()
671 create_strip_zones(mddev, &priv_conf); in raid0_takeover_raid10()
675 static void *raid0_takeover_raid1(struct mddev *mddev) in raid0_takeover_raid1() argument
683 if ((mddev->raid_disks - 1) != mddev->degraded) { in raid0_takeover_raid1()
685 mdname(mddev)); in raid0_takeover_raid1()
696 while (chunksect && (mddev->array_sectors & (chunksect - 1))) in raid0_takeover_raid1()
704 mddev->new_level = 0; in raid0_takeover_raid1()
705 mddev->new_layout = 0; in raid0_takeover_raid1()
706 mddev->new_chunk_sectors = chunksect; in raid0_takeover_raid1()
707 mddev->chunk_sectors = chunksect; in raid0_takeover_raid1()
708 mddev->delta_disks = 1 - mddev->raid_disks; in raid0_takeover_raid1()
709 mddev->raid_disks = 1; in raid0_takeover_raid1()
711 mddev->recovery_cp = MaxSector; in raid0_takeover_raid1()
712 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); in raid0_takeover_raid1()
714 create_strip_zones(mddev, &priv_conf); in raid0_takeover_raid1()
718 static void *raid0_takeover(struct mddev *mddev) in raid0_takeover() argument
727 if (mddev->bitmap) { in raid0_takeover()
729 mdname(mddev)); in raid0_takeover()
732 if (mddev->level == 4) in raid0_takeover()
733 return raid0_takeover_raid45(mddev); in raid0_takeover()
735 if (mddev->level == 5) { in raid0_takeover()
736 if (mddev->layout == ALGORITHM_PARITY_N) in raid0_takeover()
737 return raid0_takeover_raid45(mddev); in raid0_takeover()
740 mdname(mddev), ALGORITHM_PARITY_N); in raid0_takeover()
743 if (mddev->level == 10) in raid0_takeover()
744 return raid0_takeover_raid10(mddev); in raid0_takeover()
746 if (mddev->level == 1) in raid0_takeover()
747 return raid0_takeover_raid1(mddev); in raid0_takeover()
750 mddev->level); in raid0_takeover()
755 static void raid0_quiesce(struct mddev *mddev, int quiesce) in raid0_quiesce() argument