linux dentry结构,linux内核dentry结构分析

dentry,即directory entry,目录项,就是多个文件或者目录的链接,通过这个链接可以找寻到目录之下的文件或者是目录项。dentry在文件系统里是极其重要的一个概念,dentry结构体在linux内核里也是用处广泛,这个结构体定义在include/linux/dcache.h里,我们来看一下结构体的定义。

struct dentry {

atomic_t d_count;

unsigned int d_flags;/* protected by d_lock */

spinlock_t d_lock;/* per dentry lock */

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 */

struct 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 */

struct dentry_operations *d_op;

struct super_block *d_sb;/* The root of the dentry tree */

void *d_fsdata;/* fs-specific data */

#ifdef CONFIG_PROFILING

struct dcookie_struct *d_cookie; /* cookie, if any */

#endif

int d_mounted;

unsigned char d_iname[DNAME_INLINE_LEN_MIN];/* small names */

}; 下边逐个解释下。 atomic_t d_count; d_count是dentry的引用计数,多一个引用会在数值上加一,当少一个会减一,为零时会释放。 unsigned int d_flags; dentry状态位。 spinlock_t d_lock; 每一个目录结构体都有一个自旋锁。 struct inode *d_inode; 目录的inode。 struct hlist_node d_hash; 哈希链表节点,dentry被放在哈希链表dentry_cache上,方便寻找。 struct dentry *d_parent; 父目录指针。 struct qstr d_name; 文件或者是目录的名 struct list_head d_lru; lru链表 union { struct list_head d_child; /* child of parent list */ struct rcu_head d_rcu; } d_u; 父目录中目录项的指针。 struct list_head d_subdirs; 目录中子项的指针。 struct list_head d_alias; 相关索引节点的指针 unsigned long d_time; 最近使用时间 struct dentry_operations *d_op; 目录操作函数集合 struct super_block *d_sb; 目录的超级块指针 void *d_fsdata; 私有数据。 int d_mounted; 对于安装点而言表示是否被挂载文件系统,是不是一个挂载点。 unsigned char d_iname[DNAME_INLINE_LEN_MIN]; 短的文件名

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
教学内容与要求   1掌握处理器在进程地址空间上的三种运行位置,了解内核编程不能使用C库函数和FPU,以及可能产生内存故障、核心栈溢出和四种内核竞争情形的原因。(2学时)   2熟悉进程描述符的组织,进程上下文和进程状态转换,和fork,exec,wait,exit,clone,linux线程和内核线程的实现原理和应用。了解COW和避免出现孤儿进程技术。(4小时)   3介绍支持SMP的O(1)调度,用户和内核抢占和进程上下文切换,了解优先级复算,睡眠和唤醒机制,SMP的负载均衡。(4小时)   4掌握在x86体系结构上系统调用的具体实现原理,接口参数传递,用户地址空间和核心地址空间之间的数据传输,和增加新的系统功能的方法。(2小时)   5熟悉在x86体系结构Linux中断和异常的处理原理,中断注册、共享、控制,和中断上下文的意义,中断和设备驱动程序的关系,以及设备驱动程序结构和用户接口。(4小时)   6中断处理程序被分解为top half和bottom half的原因,介绍linux的softirq,tasklet,ksoftirqd和work queue,分析进程与top half,bottom half的竞争情形和同步。(4小时)   7掌握内核同步原理和方法:原子操作,自旋锁,(读—写)信号量,完成变量,bkl,seqlock和延迟内核抢占。了解指令“路障”。(4小时)   8介绍系统时钟和硬件定时器,单处理器和多处理器上的linux计时体系结构,定时的时间插补原理,单处理器和多处理器上的时钟中断处理,动态定时器的数据结构和算法原理,定时器竞争情形,延迟函数。Time,gettimeofday,adjtimex,setitimer,alarm的实现原理和应用。(4小时)   9熟悉进程地址空间的区和页,分配和释放物理页,物理地址与逻辑地址、虚地址之间的映射,slub分配原理和方法,高端物理内存的映射。(4小时)   10介绍VFS原理,超级块,inode结构和方法,dentry结构和方法,file结构和方法,以及进程打开文件表,linux中的文件系统。(2小时)   11讲解块设备缓冲,bio结构,I/O请求队列,和有最终期限的块I/O调度算法。(2小时)   12熟悉进程地址空间的分区,mm_struct结构,vm_area_struct结构和操作,,进程的页表文件映射接口mmap原理和方法。(2小时)   13熟悉页cache和radix_tree,缓冲区cache,和pdflush内核线程原理。(2小时)

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值