首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Linux内核如何处理并发文件查找

问Linux内核如何处理并发文件查找
EN

Stack Overflow用户
提问于 2012-10-17 02:42:35
回答 1查看 221关注 0票数 1

假设有两个进程同时对一个文件执行looking up操作,而这个文件还不存在于dcache中。这两个查找将向进程返回NULL (dentry)。

我的问题是,Linux内核如何确保在查找失败的dentry之后,它只创建一个dentry?

EN

回答 1

Stack Overflow用户

发布于 2012-10-17 02:54:51

代码语言:javascript
复制
1912 /**
1913  * d_lookup - search for a dentry
1914  * @parent: parent dentry
1915  * @name: qstr of name we wish to find
1916  * Returns: dentry, or NULL
1917  *
1918  * d_lookup searches the children of the parent dentry for the name in
1919  * question. If the dentry is found its reference count is incremented and the
1920  * dentry is returned. The caller must use dput to free the entry when it has
1921  * finished using it. %NULL is returned if the dentry does not exist.
1922  */

d_lookup不会自行创建任何dentry对象。看一下do_filp_open逻辑,它显示了dentries是如何创建的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12921365

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档