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()
402 blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9); in raid0_run()
403 blk_queue_io_opt(mddev->queue, in raid0_run()
404 (mddev->chunk_sectors << 9) * mddev->raid_disks); in raid0_run()
406 rdev_for_each(rdev, mddev) { in raid0_run()
407 disk_stack_limits(mddev->gendisk, rdev->bdev, in raid0_run()
413 md_set_array_sectors(mddev, raid0_size(mddev, 0, 0)); in raid0_run()
416 mdname(mddev), in raid0_run()
417 (unsigned long long)mddev->array_sectors); in raid0_run()
419 dump_zones(mddev); in raid0_run()
421 ret = md_integrity_register(mddev); in raid0_run()
428 free_conf(mddev, conf); in raid0_run()
430 acct_bioset_exit(mddev); in raid0_run()
434 static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) in raid0_handle_discard() argument
436 struct r0conf *conf = mddev->private; in raid0_handle_discard()
453 &mddev->bio_set); in raid0_handle_discard()
465 stripe_size = zone->nb_dev * mddev->chunk_sectors; in raid0_handle_discard()
473 mddev->chunk_sectors; in raid0_handle_discard()
475 mddev->chunk_sectors) + in raid0_handle_discard()
476 first_stripe_index * mddev->chunk_sectors; in raid0_handle_discard()
478 mddev->chunk_sectors; in raid0_handle_discard()
480 mddev->chunk_sectors) + in raid0_handle_discard()
481 last_stripe_index * mddev->chunk_sectors; in raid0_handle_discard()
489 mddev->chunk_sectors; in raid0_handle_discard()
491 dev_start = first_stripe_index * mddev->chunk_sectors; in raid0_handle_discard()
496 dev_end = (last_stripe_index + 1) * mddev->chunk_sectors; in raid0_handle_discard()
498 dev_end = last_stripe_index * mddev->chunk_sectors; in raid0_handle_discard()
507 md_submit_discard_bio(mddev, rdev, bio, in raid0_handle_discard()
514 static bool raid0_make_request(struct mddev *mddev, struct bio *bio) in raid0_make_request() argument
516 struct r0conf *conf = mddev->private; in raid0_make_request()
526 && md_flush_request(mddev, bio)) in raid0_make_request()
530 raid0_handle_discard(mddev, bio); in raid0_make_request()
536 chunk_sects = mddev->chunk_sectors; in raid0_make_request()
548 &mddev->bio_set); in raid0_make_request()
554 if (bio->bi_pool != &mddev->bio_set) in raid0_make_request()
555 md_account_bio(mddev, &bio); in raid0_make_request()
558 zone = find_zone(mddev->private, &sector); in raid0_make_request()
561 tmp_dev = map_sector(mddev, zone, orig_sector, &sector); in raid0_make_request()
564 tmp_dev = map_sector(mddev, zone, sector, &sector); in raid0_make_request()
567 WARN(1, "md/raid0:%s: Invalid layout\n", mdname(mddev)); in raid0_make_request()
581 if (mddev->gendisk) in raid0_make_request()
582 trace_block_bio_remap(bio, disk_devt(mddev->gendisk), in raid0_make_request()
584 mddev_check_write_zeroes(mddev, bio); in raid0_make_request()
589 static void raid0_status(struct seq_file *seq, struct mddev *mddev) in raid0_status() argument
591 seq_printf(seq, " %dk chunks", mddev->chunk_sectors / 2); in raid0_status()
595 static void *raid0_takeover_raid45(struct mddev *mddev) in raid0_takeover_raid45() argument
600 if (mddev->degraded != 1) { in raid0_takeover_raid45()
602 mdname(mddev), in raid0_takeover_raid45()
603 mddev->degraded); in raid0_takeover_raid45()
607 rdev_for_each(rdev, mddev) { in raid0_takeover_raid45()
609 if (rdev->raid_disk == mddev->raid_disks-1) { in raid0_takeover_raid45()
611 mdname(mddev)); in raid0_takeover_raid45()
614 rdev->sectors = mddev->dev_sectors; in raid0_takeover_raid45()
618 mddev->new_level = 0; in raid0_takeover_raid45()
619 mddev->new_layout = 0; in raid0_takeover_raid45()
620 mddev->new_chunk_sectors = mddev->chunk_sectors; in raid0_takeover_raid45()
621 mddev->raid_disks--; in raid0_takeover_raid45()
622 mddev->delta_disks = -1; in raid0_takeover_raid45()
624 mddev->recovery_cp = MaxSector; in raid0_takeover_raid45()
625 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); in raid0_takeover_raid45()
627 create_strip_zones(mddev, &priv_conf); in raid0_takeover_raid45()
632 static void *raid0_takeover_raid10(struct mddev *mddev) in raid0_takeover_raid10() argument
642 if (mddev->layout != ((1 << 8) + 2)) { in raid0_takeover_raid10()
644 mdname(mddev), in raid0_takeover_raid10()
645 mddev->layout); in raid0_takeover_raid10()
648 if (mddev->raid_disks & 1) { in raid0_takeover_raid10()
650 mdname(mddev)); in raid0_takeover_raid10()
653 if (mddev->degraded != (mddev->raid_disks>>1)) { in raid0_takeover_raid10()
655 mdname(mddev)); in raid0_takeover_raid10()
660 mddev->new_level = 0; in raid0_takeover_raid10()
661 mddev->new_layout = 0; in raid0_takeover_raid10()
662 mddev->new_chunk_sectors = mddev->chunk_sectors; in raid0_takeover_raid10()
663 mddev->delta_disks = - mddev->raid_disks / 2; in raid0_takeover_raid10()
664 mddev->raid_disks += mddev->delta_disks; in raid0_takeover_raid10()
665 mddev->degraded = 0; in raid0_takeover_raid10()
667 mddev->recovery_cp = MaxSector; in raid0_takeover_raid10()
668 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); in raid0_takeover_raid10()
670 create_strip_zones(mddev, &priv_conf); in raid0_takeover_raid10()
674 static void *raid0_takeover_raid1(struct mddev *mddev) in raid0_takeover_raid1() argument
682 if ((mddev->raid_disks - 1) != mddev->degraded) { in raid0_takeover_raid1()
684 mdname(mddev)); in raid0_takeover_raid1()
695 while (chunksect && (mddev->array_sectors & (chunksect - 1))) in raid0_takeover_raid1()
703 mddev->new_level = 0; in raid0_takeover_raid1()
704 mddev->new_layout = 0; in raid0_takeover_raid1()
705 mddev->new_chunk_sectors = chunksect; in raid0_takeover_raid1()
706 mddev->chunk_sectors = chunksect; in raid0_takeover_raid1()
707 mddev->delta_disks = 1 - mddev->raid_disks; in raid0_takeover_raid1()
708 mddev->raid_disks = 1; in raid0_takeover_raid1()
710 mddev->recovery_cp = MaxSector; in raid0_takeover_raid1()
711 mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); in raid0_takeover_raid1()
713 create_strip_zones(mddev, &priv_conf); in raid0_takeover_raid1()
717 static void *raid0_takeover(struct mddev *mddev) in raid0_takeover() argument
726 if (mddev->bitmap) { in raid0_takeover()
728 mdname(mddev)); in raid0_takeover()
731 if (mddev->level == 4) in raid0_takeover()
732 return raid0_takeover_raid45(mddev); in raid0_takeover()
734 if (mddev->level == 5) { in raid0_takeover()
735 if (mddev->layout == ALGORITHM_PARITY_N) in raid0_takeover()
736 return raid0_takeover_raid45(mddev); in raid0_takeover()
739 mdname(mddev), ALGORITHM_PARITY_N); in raid0_takeover()
742 if (mddev->level == 10) in raid0_takeover()
743 return raid0_takeover_raid10(mddev); in raid0_takeover()
745 if (mddev->level == 1) in raid0_takeover()
746 return raid0_takeover_raid1(mddev); in raid0_takeover()
749 mddev->level); in raid0_takeover()
754 static void raid0_quiesce(struct mddev *mddev, int quiesce) in raid0_quiesce() argument