RAID5 IO处理之重构代码详解( 五 )

4 激活热备盘重构完成后需要将热备盘设置为正常状态开始使用,函数调用关系如下:
md_do_sync() \_ md_wakeup_thread() /* raid5d */ \_ raid5d()\_ md_check_recovery()\_ md_reap_sync_thread()\_ raid5_spare_active()代码逻辑如下:
static int raid5_spare_active(struct mddev *mddev){ int i; struct r5conf *conf = mddev->private; struct disk_info *tmp; int count = 0; unsigned long flags; for (i = 0; i < conf->raid_disks; i++) {tmp = conf->disks + i;/* test_and_set_bit中设置成员磁盘状态为In_sync,即处于同步状态 */if (tmp->rdev&& tmp->rdev->recovery_offset == MaxSector&& !test_bit(Faulty, &tmp->rdev->flags)&& !test_and_set_bit(In_sync, &tmp->rdev->flags)) {count++;sysfs_notify_dirent_safe(tmp->rdev->sysfs_state);} } /* 计算md降级状态 */ spin_lock_irqsave(&conf->device_lock, flags); mddev->degraded = calc_degraded(conf); spin_unlock_irqrestore(&conf->device_lock, flags); return count;}

经验总结扩展阅读