linux内核md源代码解读 五 先容raidd5阵列的运行
发布时间:2016-10-30 13:50:05 所属栏目:Linux 来源:站长网
导读:副标题#e# 如果看懂了raid1阵列的run函数,那么看raid5阵列run就非常轻松了,因为两者要做的事情都是大同小异。 raid5的run函数很长,但很大一部分跟创建运行是没有关系的,特别是有一段跟reshape相关的,大多数系统都不关注该功能,因此可以直接跳过。经过
5252行,申请struct stripe_head slab。跟进函数grow_stripes: 1501 static int grow_stripes(struct r5conf *conf, int num) 1502 { 1503 struct kmem_cache *sc; 1504 int devs = max(conf->raid_disks, conf->previous_raid_disks); 1505 1506 if (conf->mddev->gendisk) 1507 sprintf(conf->cache_name[0], 1508 "raid%d-%s", conf->level, mdname(conf->mddev)); 1509 else 1510 sprintf(conf->cache_name[0], 1511 "raid%d-%p", conf->level, conf->mddev); 1512 sprintf(conf->cache_name[1], "%s-alt", conf->cache_name[0]); 1513 1514 conf->active_name = 0; 1515 sc = kmem_cache_create(conf->cache_name[conf->active_name], 1516 sizeof(struct stripe_head)+(devs-1)*sizeof(struct r5dev), 1517 0, 0, NULL); 1518 if (!sc) 1519 return 1; 1520 conf->slab_cache = sc; 1521 conf->pool_size = devs; 1522 while (num--) 1523 if (!grow_one_stripe(conf)) 1524 return 1; 1525 return 0; 1526 } 1504行,计算数据盘数目。 1506行,设置slab名称。 1515行,创建slab, 空间大小为sizeof(struct stripe_head)+(devs-1)*sizeof(struct r5dev)是因为struct stripe_head尾部有devs个struct r5dev。 (编辑:云计算网_泰州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |