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.
阅读(1035) | 评论(0) | 转发(0) |