diff options
author | Krzysztof Wojcik <krzysztof.wojcik@intel.com> | 2011-01-30 21:47:13 -0500 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-01-30 21:47:13 -0500 |
commit | fc3a08b85b7a4f6c1069e5f71f6ad40d925ff55b (patch) | |
tree | 1d23e67decd38615a38a50769c264f3a2636d582 /drivers/md | |
parent | f21e9ff7f77d41ceca4e1e5ee5a4efa5ad7a5e40 (diff) |
Add raid1->raid0 takeover support
This patch introduces raid 1 to raid0 takeover operation
in kernel space.
Signed-off-by: Krzysztof Wojcik <krzysztof.wojcik@intel.com>
Signed-off-by: Neil Brown <neilb@nbeee.brown>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/raid0.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index a39f4c355e55..637a96855edb 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -179,6 +179,14 @@ static int create_strip_zones(mddev_t *mddev, raid0_conf_t **private_conf) | |||
179 | rdev1->new_raid_disk = j; | 179 | rdev1->new_raid_disk = j; |
180 | } | 180 | } |
181 | 181 | ||
182 | if (mddev->level == 1) { | ||
183 | /* taiking over a raid1 array- | ||
184 | * we have only one active disk | ||
185 | */ | ||
186 | j = 0; | ||
187 | rdev1->new_raid_disk = j; | ||
188 | } | ||
189 | |||
182 | if (j < 0 || j >= mddev->raid_disks) { | 190 | if (j < 0 || j >= mddev->raid_disks) { |
183 | printk(KERN_ERR "md/raid0:%s: bad disk number %d - " | 191 | printk(KERN_ERR "md/raid0:%s: bad disk number %d - " |
184 | "aborting!\n", mdname(mddev), j); | 192 | "aborting!\n", mdname(mddev), j); |
@@ -644,12 +652,38 @@ static void *raid0_takeover_raid10(mddev_t *mddev) | |||
644 | return priv_conf; | 652 | return priv_conf; |
645 | } | 653 | } |
646 | 654 | ||
655 | static void *raid0_takeover_raid1(mddev_t *mddev) | ||
656 | { | ||
657 | raid0_conf_t *priv_conf; | ||
658 | |||
659 | /* Check layout: | ||
660 | * - (N - 1) mirror drives must be already faulty | ||
661 | */ | ||
662 | if ((mddev->raid_disks - 1) != mddev->degraded) { | ||
663 | printk(KERN_ERR "md/raid0:%s: (N - 1) mirrors drives must be already faulty!\n", | ||
664 | mdname(mddev)); | ||
665 | return ERR_PTR(-EINVAL); | ||
666 | } | ||
667 | |||
668 | /* Set new parameters */ | ||
669 | mddev->new_level = 0; | ||
670 | mddev->new_layout = 0; | ||
671 | mddev->new_chunk_sectors = 128; /* by default set chunk size to 64k */ | ||
672 | mddev->delta_disks = 1 - mddev->raid_disks; | ||
673 | /* make sure it will be not marked as dirty */ | ||
674 | mddev->recovery_cp = MaxSector; | ||
675 | |||
676 | create_strip_zones(mddev, &priv_conf); | ||
677 | return priv_conf; | ||
678 | } | ||
679 | |||
647 | static void *raid0_takeover(mddev_t *mddev) | 680 | static void *raid0_takeover(mddev_t *mddev) |
648 | { | 681 | { |
649 | /* raid0 can take over: | 682 | /* raid0 can take over: |
650 | * raid4 - if all data disks are active. | 683 | * raid4 - if all data disks are active. |
651 | * raid5 - providing it is Raid4 layout and one disk is faulty | 684 | * raid5 - providing it is Raid4 layout and one disk is faulty |
652 | * raid10 - assuming we have all necessary active disks | 685 | * raid10 - assuming we have all necessary active disks |
686 | * raid1 - with (N -1) mirror drives faulty | ||
653 | */ | 687 | */ |
654 | if (mddev->level == 4) | 688 | if (mddev->level == 4) |
655 | return raid0_takeover_raid45(mddev); | 689 | return raid0_takeover_raid45(mddev); |
@@ -665,6 +699,12 @@ static void *raid0_takeover(mddev_t *mddev) | |||
665 | if (mddev->level == 10) | 699 | if (mddev->level == 10) |
666 | return raid0_takeover_raid10(mddev); | 700 | return raid0_takeover_raid10(mddev); |
667 | 701 | ||
702 | if (mddev->level == 1) | ||
703 | return raid0_takeover_raid1(mddev); | ||
704 | |||
705 | printk(KERN_ERR "Takeover from raid%i to raid0 not supported\n", | ||
706 | mddev->level); | ||
707 | |||
668 | return ERR_PTR(-EINVAL); | 708 | return ERR_PTR(-EINVAL); |
669 | } | 709 | } |
670 | 710 | ||