Linux虚拟文件系统在内核初始化的start_kernel()函数中主要调用两个函数来实现。 [cpp] - asmlinkage void __init start_kernel(void)
- {
- ……
- vfs_caches_init_early();
- ……
- vfs_caches_init(totalram_pages);
- ……
- }
一、早期初始化虚拟文件系统的早期初始化有函数vfs_caches_init_early()实现,主要负责dentry和inode的hashtable的初始化工作。
[cpp] - /*在start_kernel中调用,用于文件系统中早期的初始化*/
- void __init vfs_caches_init_early(void)
- {
- /*初始化两个hashtable*/
- dcache_init_early();
- inode_init_early();
- }
1.1 dcache[cpp] - static void __init dcache_init_early(void)
- {
- int loop;
-
- /* If hashes are distributed across NUMA nodes, defer
- * hash allocation until vmalloc space is available.
- */
- if (hashdist)
- return;
- /*dentry hashtable的空间分配*/
- dentry_hashtable =
- alloc_large_system_hash("Dentry cache",
- sizeof(struct hlist_head),
- dhash_entries,
- 13,
- HASH_EARLY,
- &d_hash_shift,
- &d_hash_mask,
- 0);
- /*hashtable的各个链表初始化*/
- for (loop = 0; loop < (1 << d_hash_shift); loop++)
- INIT_HLIST_HEAD(&dentry_hashtable[loop]);
- }
1.2 inode[cpp] - /*
- * Initialize the waitqueues and inode hash table.
- */
- void __init inode_init_early(void)
- {
- int loop;
-
- /* If hashes are distributed across NUMA nodes, defer
- * hash allocation until vmalloc space is available.
- */
- if (hashdist)
- return;
- /*从cache中分配inode hashtable的内存空间*/
- inode_hashtable =
- alloc_large_system_hash("Inode-cache",
- sizeof(struct hlist_head),
- ihash_entries,
- 14,
- HASH_EARLY,
- &i_hash_shift,
- &i_hash_mask,
- 0);
- /*初始化hashtable 的各个链表*/
- for (loop = 0; loop < (1 << i_hash_shift); loop++)
- INIT_HLIST_HEAD(&inode_hashtable[loop]);
- }
从普通用户的角度再看Kubuntu 11.10和Chakra 2011.09(Edn)Linux虚拟文件系统(内核初始化<二>)相关资讯 Linux基础教程
- Linux基础教程:对文件打包压缩 (03月08日)
- 基础教程:Linux 新手应该知道的 (09/06/2015 21:17:20)
- Linux基础教程:find 与 xargs (04/05/2015 10:20:11)
| - Linux基础教程:tar 命令使用介绍 (12/03/2015 13:19:47)
- Linux基础教程(1)操作系统基础 (08/15/2015 20:44:01)
- Linux基础教程:从源码安装软件 (04/05/2015 10:14:45)
|
本文评论 查看全部评论 (0)