linux内核md源代码解读 五 先容raidd5阵列的运行
发布时间:2016-11-03 19:39:00 所属栏目:Linux 来源:站长网
导读:副标题#e# 如果看懂了raid1阵列的run函数,那么看raid5阵列run就非常轻松了,因为两者要做的事情都是大同小异。 raid5的run函数很长,但很大一部分跟创建运行是没有关系的,特别是有一段跟reshape相关的,大多数系统都不关注该功能,因此可以直接跳过。经过
|
1523行,创建空闲struct stripe_head。然而只是简单地创建就没有必要跟进看了,但该函数中隐藏着一个最经常调用的函数release_stripe,所以还是有必要跟进的:
1477 static int grow_one_stripe(struct r5conf *conf)
1478 {
1479 struct stripe_head *sh;
1480 sh = kmem_cache_zalloc(conf->slab_cache, GFP_KERNEL);
1481 if (!sh)
1482 return 0;
1483
1484 sh->raid_conf = conf;
1485
1486 spin_lock_init(&sh->stripe_lock);
1487
1488 if (grow_buffers(sh)) {
1489 shrink_buffers(sh);
1490 kmem_cache_free(conf->slab_cache, sh);
1491 return 0;
1492 }
1493 /* we just created an active stripe so... */
1494 atomic_set(&sh->count, 1);
1495 atomic_inc(&conf->active_stripes);
1496 INIT_LIST_HEAD(&sh->lru);
1497 release_stripe(sh);
1498 return 1;
1499 }
查看本栏目更多精彩内容:http://www.bianceng.cn/OS/Linux/ (编辑:温州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

