linux内核奇遇记之md源代码解读之六
linux内核奇遇记之md源代码解读之六转载请注明出处:http://blog.csdn.net/liumangxiong
raid10的run函数与raid5的run函数最大区别在于setup_conf,那就直接深入核心:
3468 static void calc_sectors(struct r10conf *conf, sector_t size)3469 {3470 /* Calculate the number of sectors-per-device that will3471 * actually be used, and set conf->dev_sectors and3472 * conf->stride3473 */3474 3475 size = size >> conf->geo.chunk_shift;3476 sector_div(size, conf->geo.far_copies);3477 size = size * conf->geo.raid_disks;3478 sector_div(size, conf->geo.near_copies);3479 /* 'size' is now the number of chunks in the array */3480 /* calculate "used chunks per device" */3481 size = size * conf->copies;3482 3483 /* We need to round up when dividing by raid_disks to3484 * get the stride size.3485 */3486 size = DIV_ROUND_UP_SECTOR_T(size, conf->geo.raid_disks);3487 3488 conf->dev_sectors = size << conf->geo.chunk_shift;3489 3490 if (conf->geo.far_offset)3491 conf->geo.stride = 1 << conf->geo.chunk_shift;3492 else {3493 sector_div(size, conf->geo.far_copies);3494 conf->geo.stride = size << conf->geo.chunk_shift;3495 }3496 }