- 论坛徽章:
- 0
|
最近在看2.4内核VFS部分的代码,看到path_walk里边通过cached_lookup在内存中查找dentry的时候,感觉cached_lookup里边有一个地方是不是一个Bug?
cached_lookup()的代码:
- static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name, int flags)
- {
- struct dentry * dentry = d_lookup(parent, name);
- if (dentry && dentry->d_op && dentry->d_op->d_revalidate) {
- if (!dentry->d_op->d_revalidate(dentry, flags) && !d_invalidate(dentry)) {
- dput(dentry);
- dentry = NULL;
- }
- }
- return dentry;
- }
复制代码
在d_revalidate验证dentry不可用的情况下,需要d_invalidate来释放该dentry的时候,如果dentry忙,没有成功释放,那么还是会将这个不可用的dentry返回,这个地方会不会是一个Bug呢?
在看d_invalidate()函数的内容:
- …………
- if (atomic_read(&dentry->d_count) > 1) {
- if (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode)) {
- spin_unlock(&dcache_lock);
- return -EBUSY;
- }
- }
- …………
复制代码
虽然在计数器大于1,也就是有其地方在使用这个dentry时,但也要该dentry对应的inode有效,且描述的是一个目录时,才返回BUSY,此时cached_lookup就返回了一个文件系统认为不可用的dentry给path_walk。这究竟是一个Bug,还是在内核的其他地方有补充来避免这种现象?
小弟对内核VFS这部分了解的不够全面,希望大家帮忙。 |
|