Chinaunix首页 | 论坛 | 博客
  • 博客访问: 346117
  • 博文数量: 168
  • 博客积分: 6895
  • 博客等级: 准将
  • 技术积分: 1726
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-12 23:01
文章分类

全部博文(168)

文章存档

2011年(6)

2010年(162)

我的朋友

分类: LINUX

2010-10-28 01:19:48

              会议记录
时间:2010 年 10 月 25 日,下午 2 点.
记录者:贾威.
讨论者:赵桥,王祥,李聪,乌云,刘亚运,
张波,兰项羽,贾威.
会议主题:
        总结文件系统的有关理论知识.
会议内容:
         这次会议大家主要讨论了有关文件系统的一些理
论知识,主要是回顾了周报告中的每个人有关文件系统部分
的困惑。还确定了下次会议的重点--概括出写一个文件系
统的步骤,重要的结构体。。。。。。还确立了每次会议记
录者--贾威。下面就这次会议中主要讨论的一些问题作以
下介绍.
问题一:如果要找某一个特定的文件,内核如何处理?
      首先会在目录项缓存中查找,注意这里是通过哈西
函数查找的,而且查找顺序为从右向左(例
如/usr/src/jiawei.c,会从 jiawei.c 开始到根目录,这
样的效率很高)。如果缓存中没有,那么文件系统会从根目
录开始找起,逐级查找。具体是这样,先找到/目录的
dentry,然后会找到他的 inode,他的 inode 会有一项专门
记录其下一级的所有 dentry,找到对应的 dentry,然后就
这样一直找到所要找的文件(注意 linux 下面没有目录)。
问题二:vfs 中的 dentry 结构体中的 vunsigned 类型?
       如下是在网上下载的源码:
struct dentry {
atomic_t d_count; 目录项对象使用计数器
unsigned int d_flags; 目录项标志
struct inode * d_inode;与文件名关联的索引节点****
************************从该指针找到 inode 从而找
到所要找的文件(应该是这样)
struct  dentry * d_parent; 父目录的目录项对象
struct  list_head d_hash; 散列表表项的指针
struct  list_head d_lru; 未使用链表的指针
struct  list_head d_child; 父目录中目录项对象的链
表的指针
struct list_head d_subdirs;对目录而言,表示子目录
目录项对象的链表
struct list_head d_alias; 相关索引节点(别名)的
链表
int d_mounted; 对于安装点而言,表示被安装文件系统根

struct qstr d_name; 文件名
unsigned long d_time; /* used by d_revalidate
*/
struct dentry_operations *d_op; 目录项方法
struct super_block * d_sb; 文件的超级块对象
vunsigned long d_vfs_flags;
void * d_fsdata;与文件系统相关的数据
unsigned char d_iname [DNAME_INLINE_LEN]; 存放
短文件名
};
事实上 kernel 早就不用这个数据类型了,你可以找找最近
2.6 版的,找不到了,下面是 2.6.34.4 的 dentry 源码。
struct dentry {
 atomic_t d_count;
unsigned int d_flags; /* protected by d_lock */
 spinlock_t d_lock;/* per dentry lock */
 int d_mounted;
 struct inode *d_inode; /* Where the name belongs
to - NULL is
* negative */
 /*
* The next three fields are touched by
__d_lookup.Place them here
* so they all fit in a cache line.
 */
 struct hlist_node d_hash;/* lookup hash list */
 struct dentry *d_parent; /* parent directory */
 struct qstr d_name;
 struct list_head d_lru;/* LRU list */
/*
* d_child and d_rcu can share memory
*/
 union {
 struct list_head d_child/* child of parent list */
truct rcu_head d_rcu;
 } d_u;
 struct list_head d_subdirs;/* our children */
struct list_head d_alias;/* inode alias list */
 unsigned long d_time;/* used by d_revalidate */
const struct dentry_operations *d_op;
struct super_block *d_sb;/* The root of the dentry
tree */
 void *d_fsdata;/* fs-specific data */
 unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /*
small names */
};
问题三:dentry 中的 d_inode 指向的的是哪个 inode?
      切记这里指向的是本 dentry 的 inode,而不是下
一级的 inode。
  以上就是本次会议的记录。如果哪位同学有关于文件系
统方面的疑问,请以群发邮件的方式提问,大家可以共同探
讨。

阅读(410) | 评论(0) | 转发(0) |
0

上一篇:10 27

下一篇:10 28

给主人留下些什么吧!~~