Commit 8ee83145 authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

[PATCH] MD - Add in_sync flag to each rdev

Add in_sync flag to each rdev

This currently mirrors the MD_DISK_SYNC superblock flag,
but soon it will be authoritative and the superblock will
only be consulted at start time.
parent 9347ddf5
...@@ -1179,9 +1179,19 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1179,9 +1179,19 @@ static int analyze_sbs(mddev_t * mddev)
rdev->alias_device = !!i; rdev->alias_device = !!i;
rdev->desc_nr = i++; rdev->desc_nr = i++;
rdev->raid_disk = rdev->desc_nr; rdev->raid_disk = rdev->desc_nr;
rdev->in_sync = 1;
} else { } else {
mdp_disk_t *desc;
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; desc = sb->disks + rdev->desc_nr;
rdev->raid_disk = desc->raid_disk;
rdev->in_sync = rdev->faulty = 0;
if (desc->state & (1<<MD_DISK_FAULTY))
rdev->faulty = 1;
else if (desc->state & (1<<MD_DISK_SYNC) &&
rdev->raid_disk < mddev->sb-raid_disks)
rdev->in_sync = 1;
} }
} }
/* /*
...@@ -2110,6 +2120,11 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) ...@@ -2110,6 +2120,11 @@ 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; rdev->raid_disk = info->raid_disk;
rdev->faulty = 0;
if (rdev->raid_disk < mddev->sb->raid_disks)
rdev->in_sync = (info->state & (1<<MD_DISK_SYNC));
else
rdev->in_sync = 0;
bind_rdev_to_array(rdev, mddev); bind_rdev_to_array(rdev, mddev);
...@@ -2271,6 +2286,7 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev) ...@@ -2271,6 +2286,7 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev)
err = -EINVAL; err = -EINVAL;
goto abort_export; goto abort_export;
} }
rdev->in_sync = 0;
bind_rdev_to_array(rdev, mddev); bind_rdev_to_array(rdev, mddev);
/* /*
...@@ -2852,6 +2868,7 @@ int md_error(mddev_t *mddev, struct block_device *bdev) ...@@ -2852,6 +2868,7 @@ int md_error(mddev_t *mddev, struct block_device *bdev)
if (!mddev->pers->error_handler if (!mddev->pers->error_handler
|| mddev->pers->error_handler(mddev,bdev) <= 0) { || mddev->pers->error_handler(mddev,bdev) <= 0) {
rrdev->faulty = 1; rrdev->faulty = 1;
rrdev->in_sync = 0;
} else } else
return 1; return 1;
/* /*
......
...@@ -726,6 +726,7 @@ static int raid1_spare_active(mddev_t *mddev) ...@@ -726,6 +726,7 @@ static int raid1_spare_active(mddev_t *mddev)
failed_rdev->desc_nr = spare_desc->number; failed_rdev->desc_nr = spare_desc->number;
failed_rdev->raid_disk = spare_disk; failed_rdev->raid_disk = spare_disk;
} }
spare_rdev->in_sync = 1;
xchg_values(*spare_desc, *failed_desc); xchg_values(*spare_desc, *failed_desc);
xchg_values(*fdisk, *sdisk); xchg_values(*fdisk, *sdisk);
......
...@@ -1751,6 +1751,7 @@ static int raid5_spare_active(mddev_t *mddev) ...@@ -1751,6 +1751,7 @@ static int raid5_spare_active(mddev_t *mddev)
failed_rdev->desc_nr = spare_desc->number; failed_rdev->desc_nr = spare_desc->number;
failed_rdev->raid_disk = spare_disk; failed_rdev->raid_disk = spare_disk;
} }
spare_rdev->in_sync = 1;
xchg_values(*spare_desc, *failed_desc); xchg_values(*spare_desc, *failed_desc);
xchg_values(*fdisk, *sdisk); xchg_values(*fdisk, *sdisk);
......
...@@ -158,6 +158,8 @@ struct mdk_rdev_s ...@@ -158,6 +158,8 @@ 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 in_sync; /* device is a full member of the array */
int desc_nr; /* descriptor index in the superblock */ int desc_nr; /* descriptor index in the superblock */
int raid_disk; /* role of device in array */ int raid_disk; /* role of device in array */
}; };
......
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