触碰虚拟文件系统

5.6 触碰虚拟文件系统

回到start_kernel中,下面我们该第一次接触文件系统了,582行执行vfs_caches_init_early

 

void __init vfs_caches_init_early(void)

{

       dcache_init_early();

       inode_init_early();

}

 

vfs_caches_init_early调用两个函数dcache_init_earlyinode_init_early。内核第一次触碰文件系统的主要目的就是初始化VFS的两个重要数据结构dcacheinode的缓存。

dcache_init_early来自fs/dcache.c

 

2287static void __init dcache_init_early(void)

2288{

2289        int loop;

2290

2291        /* If hashes are distributed across NUMA nodes, defer

2292         * hash allocation until vmalloc space is available.

2293         */

2294        if (hashdist)

2295                return;

2296

2297        dentry_hashtable =

2298                alloc_large_system_hash("Dentry cache",

2299                                        sizeof(struct hlist_head),

2300                                        dhash_entries,

2301                                        13,

2302                                        HASH_EARLY,

2303                                        &d_hash_shift,

2304                                        &d_hash_mask,

2305                                        0);

2306

2307        for (loop = 0; loop < (1 << d_hash_shift); loop++)

2308                INIT_HLIST_HEAD(&dentry_hashtable[loop]);

2309}

 

inode_init_early来自fs/inode.c

 

1539void __init inode_init_early(void)

1540{

1541        int loop;

1542

1543        /* If hashes are distributed across NUMA nodes, defer

1544         * hash allocation until vmalloc space is available.

1545         */

1546        if (hashdist)

1547                return;

1548

1549        inode_hashtable =

1550                alloc_large_system_hash("Inode-cache",

1551                                        sizeof(struct hlist_head),

1552                                        ihash_entries,

1553                                        14,

1554                                        HASH_EARLY,

1555                                        &i_hash_shift,

1556                                        &i_hash_mask,

1557                                        0);

1558

1559        for (loop = 0; loop < (1 << i_hash_shift); loop++)

1560                INIT_HLIST_HEAD(&inode_hashtable[loop]);

1561}

 

两个函数都是调用alloc_large_system_hash函数分别为dentry_hashtableinode_hashtable分配空间。至于这两个散列的用途,请参考博客“把Linux中的VFS对象串联起来”http://blog.csdn.net/yunsongice/archive/2010/06/21/5683859.aspx

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值