免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1525 | 回复: 0
打印 上一主题 下一主题

ext3目录查找 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-21 23:34 |只看该作者 |倒序浏览
2010/1/2 下午
感冒 ,犯困,喝了茶来提神,趁清醒的时候,想深入看看ext3_lookup检索某个dentry对应的inode的流程,这便于了解ext3的disk上数据布局,以及理解目录索引是如何高效的。。。。可是,,这部分实在是太太太太复杂了。。。
1) 对buffer机制的使用细节没有研究过
2) 对ext3的dir的目录分布及内容存储没有实际的实验经验。
3) 对于hash存储的一些拓扑结构不理解。
所以在具体的函数查找时,真是很费劲。。。
我简要说几个items,方便后面回来索引吧。。。
1。 ext3_lookup的caller
当inode为目录是,其i-op指向ext3_dir_inode_operations.
kernel有inode/dentry cache, when search a "file name entry",it will call __do_lookup() to get *dentry from hash table. qstr stores name and hash value, it will calculates special hash values and search from parent's hash head list.
if above lookup fails,it will call real_lookup() to do the work.
as we can guess,now there's no dentry exist,we need first d_alloc such one,next ,we should find it's inode and bind them together.
this part code is:
dentry = d_alloc(parent, name);
parent-inode->i_op->lookup()
Now, we comes to ext3_lookup();
2. ext3_lookup()
this function wil do 3 steps:
a: ext3_find_entry() to search from parent dir's inode data block,use come very flexible mechasim to get the ext3_dir_entry_2,, refer to above picture of dir.
b: one finish a,we get entry to know name-->inode-num,we need check it's valid and call ext3_iget() to return the *inode locates in memory. this function is very interesting, it build up memory inode information for vfs. ofcourse it will read disk inode values,and fill up some inode fields in memory.
c: now we have inode and dentry,need bind them together by calling d_splice_alias();it will add dentry to hash list.
about item a: we know in ext2, the search work is one by one compare work. in ext3 ,we use hash search way first,if fail, we use tranditional way.
Hash way:ext3_dx_find_entry();
old fashioned way:
for(parent's inode data blocks){
readahead buffer;
search in this buffer to locate the dir entry;
if okay,return buffer head pointer;
}
Most important, note ext3's journal mechasim. know where to start/stop,alittle understanding jbd layer's work model.
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/110888/showart_2156666.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP