Commit 9347ddf5 authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

[PATCH] MD - Add raid_disk field to rdev

Add raid_disk field to rdev

Also change find_rdev_nr to find based on position
in array (raid_disk) not position in superblock (number).
parent 82081640
...@@ -52,7 +52,7 @@ static int linear_run (mddev_t *mddev) ...@@ -52,7 +52,7 @@ static int linear_run (mddev_t *mddev)
conf->smallest = NULL; conf->smallest = NULL;
cnt = 0; cnt = 0;
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
int j = rdev->sb->this_disk.raid_disk; int j = rdev->raid_disk;
dev_info_t *disk = conf->disks + j; dev_info_t *disk = conf->disks + j;
if (j < 0 || j > mddev->sb->raid_disks || disk->bdev) { if (j < 0 || j > mddev->sb->raid_disks || disk->bdev) {
......
...@@ -242,7 +242,7 @@ mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr) ...@@ -242,7 +242,7 @@ mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr)
struct list_head *tmp; struct list_head *tmp;
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
if (rdev->desc_nr == nr) if (rdev->raid_disk == nr)
return rdev; return rdev;
} }
return NULL; return NULL;
...@@ -1178,8 +1178,11 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1178,8 +1178,11 @@ static int analyze_sbs(mddev_t * mddev)
if (sb->level == LEVEL_MULTIPATH) { if (sb->level == LEVEL_MULTIPATH) {
rdev->alias_device = !!i; rdev->alias_device = !!i;
rdev->desc_nr = i++; rdev->desc_nr = i++;
} else rdev->raid_disk = rdev->desc_nr;
} else {
rdev->desc_nr = rdev->sb->this_disk.number; rdev->desc_nr = rdev->sb->this_disk.number;
rdev->raid_disk = sb->disks[rdev->desc_nr].raid_disk;
}
} }
/* /*
* Fix up changed device names ... but only if this disk has a * Fix up changed device names ... but only if this disk has a
...@@ -2106,6 +2109,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) ...@@ -2106,6 +2109,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
} }
rdev->old_dev = dev; rdev->old_dev = dev;
rdev->desc_nr = info->number; rdev->desc_nr = info->number;
rdev->raid_disk = info->raid_disk;
bind_rdev_to_array(rdev, mddev); bind_rdev_to_array(rdev, mddev);
......
...@@ -713,16 +713,19 @@ static int raid1_spare_active(mddev_t *mddev) ...@@ -713,16 +713,19 @@ static int raid1_spare_active(mddev_t *mddev)
/* /*
* do the switch finally * do the switch finally
*/ */
spare_rdev = find_rdev_nr(mddev, spare_desc->number); spare_rdev = find_rdev_nr(mddev, spare_disk);
failed_rdev = find_rdev_nr(mddev, failed_desc->number); failed_rdev = find_rdev_nr(mddev, failed_disk);
/* /*
* There must be a spare_rdev, but there may not be a * There must be a spare_rdev, but there may not be a
* failed_rdev. That slot might be empty... * failed_rdev. That slot might be empty...
*/ */
spare_rdev->desc_nr = failed_desc->number; spare_rdev->desc_nr = failed_desc->number;
if (failed_rdev) spare_rdev->raid_disk = failed_disk;
if (failed_rdev) {
failed_rdev->desc_nr = spare_desc->number; failed_rdev->desc_nr = spare_desc->number;
failed_rdev->raid_disk = spare_disk;
}
xchg_values(*spare_desc, *failed_desc); xchg_values(*spare_desc, *failed_desc);
xchg_values(*fdisk, *sdisk); xchg_values(*fdisk, *sdisk);
......
...@@ -1739,15 +1739,18 @@ static int raid5_spare_active(mddev_t *mddev) ...@@ -1739,15 +1739,18 @@ static int raid5_spare_active(mddev_t *mddev)
/* /*
* do the switch finally * do the switch finally
*/ */
spare_rdev = find_rdev_nr(mddev, spare_desc->number); spare_rdev = find_rdev_nr(mddev, spare_disk);
failed_rdev = find_rdev_nr(mddev, failed_desc->number); failed_rdev = find_rdev_nr(mddev, failed_disk);
/* There must be a spare_rdev, but there may not be a /* There must be a spare_rdev, but there may not be a
* failed_rdev. That slot might be empty... * failed_rdev. That slot might be empty...
*/ */
spare_rdev->desc_nr = failed_desc->number; spare_rdev->desc_nr = failed_desc->number;
if (failed_rdev) spare_rdev->raid_disk = failed_disk;
if (failed_rdev) {
failed_rdev->desc_nr = spare_desc->number; failed_rdev->desc_nr = spare_desc->number;
failed_rdev->raid_disk = spare_disk;
}
xchg_values(*spare_desc, *failed_desc); xchg_values(*spare_desc, *failed_desc);
xchg_values(*fdisk, *sdisk); xchg_values(*fdisk, *sdisk);
......
...@@ -159,6 +159,7 @@ struct mdk_rdev_s ...@@ -159,6 +159,7 @@ struct mdk_rdev_s
int alias_device; /* device alias to the same disk */ int alias_device; /* device alias to the same disk */
int faulty; /* if faulty do not issue IO requests */ int faulty; /* if faulty do not issue IO requests */
int desc_nr; /* descriptor index in the superblock */ int desc_nr; /* descriptor index in the superblock */
int raid_disk; /* role of device in array */
}; };
typedef struct mdk_personality_s mdk_personality_t; typedef struct mdk_personality_s mdk_personality_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment