inode节点查找
来源:互联网 发布:简单订餐系统asp源码 编辑:程序博客网 时间:2024/05/29 09:19
节点查找,查找是利用前面介绍的hash值进行:
/** * ilookup - search for an inode in the inode cache * @sb:super block of file system to search * @ino:inode number to search for * * Search for the inode @ino in the inode cache, and if the inode is in the * cache, the inode is returned with an incremented reference count. */struct inode *ilookup(struct super_block *sb, unsigned long ino){struct hlist_head *head = inode_hashtable + hash(sb, ino);struct inode *inode;again:spin_lock(&inode_hash_lock);inode = find_inode_fast(sb, head, ino);spin_unlock(&inode_hash_lock);if (inode) {wait_on_inode(inode);if (unlikely(inode_unhashed(inode))) {iput(inode);goto again;}}return inode;}
/** * ilookup5 - search for an inode in the inode cache * @sb:super block of file system to search * @hashval:hash value (usually inode number) to search for * @test:callback used for comparisons between inodes * @data:opaque data pointer to pass to @test * * Search for the inode specified by @hashval and @data in the inode cache, * and if the inode is in the cache, return the inode with an incremented * reference count. Waits on I_NEW before returning the inode. * returned with an incremented reference count. * * This is a generalized version of ilookup() for file systems where the * inode number is not sufficient for unique identification of an inode. * * Note: @test is called with the inode_hash_lock held, so can't sleep. */struct inode *ilookup5(struct super_block *sb, unsigned long hashval,int (*test)(struct inode *, void *), void *data){struct inode *inode;again:inode = ilookup5_nowait(sb, hashval, test, data);if (inode) {wait_on_inode(inode);if (unlikely(inode_unhashed(inode))) {iput(inode);goto again;}}return inode;}
/** * ilookup5_nowait - search for an inode in the inode cache * @sb:super block of file system to search * @hashval:hash value (usually inode number) to search for * @test:callback used for comparisons between inodes * @data:opaque data pointer to pass to @test * * Search for the inode specified by @hashval and @data in the inode cache. * If the inode is in the cache, the inode is returned with an incremented * reference count. * * Note: I_NEW is not waited upon so you have to be very careful what you do * with the returned inode. You probably should be using ilookup5() instead. * * Note2: @test is called with the inode_hash_lock held, so can't sleep. */struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval,int (*test)(struct inode *, void *), void *data){struct hlist_head *head = inode_hashtable + hash(sb, hashval);struct inode *inode;spin_lock(&inode_hash_lock);inode = find_inode(sb, head, test, data);spin_unlock(&inode_hash_lock);return inode;}EXPORT_SYMBOL(ilookup5_nowait);
/** * find_inode_nowait - find an inode in the inode cache * @sb:super block of file system to search * @hashval:hash value (usually inode number) to search for * @match:callback used for comparisons between inodes * @data:opaque data pointer to pass to @match * * Search for the inode specified by @hashval and @data in the inode * cache, where the helper function @match will return 0 if the inode * does not match, 1 if the inode does match, and -1 if the search * should be stopped. The @match function must be responsible for * taking the i_lock spin_lock and checking i_state for an inode being * freed or being initialized, and incrementing the reference count * before returning 1. It also must not sleep, since it is called with * the inode_hash_lock spinlock held. * * This is a even more generalized version of ilookup5() when the * function must never block --- find_inode() can block in * __wait_on_freeing_inode() --- or when the caller can not increment * the reference count because the resulting iput() might cause an * inode eviction. The tradeoff is that the @match funtion must be * very carefully implemented. */struct inode *find_inode_nowait(struct super_block *sb,unsigned long hashval,int (*match)(struct inode *, unsigned long, void *),void *data){struct hlist_head *head = inode_hashtable + hash(sb, hashval);struct inode *inode, *ret_inode = NULL;int mval;spin_lock(&inode_hash_lock);hlist_for_each_entry(inode, head, i_hash) {if (inode->i_sb != sb)continue;mval = match(inode, hashval, data);if (mval == 0)continue;if (mval == 1)ret_inode = inode;goto out;}out:spin_unlock(&inode_hash_lock);return ret_inode;}
0 0
- inode节点查找
- 理解“索引节点”inode
- inode索引节点---初识
- inode节点销毁
- inode节点简单统计
- inode节点hash处理
- inode节点clear操作
- linux i节点(inode)
- linux inode节点详解
- Linux inode节点
- linux 索引节点 inode 详解
- 深入理解linux 节点inode
- inode索引节点的概念
- linux 索引节点 inode 详解
- 查找节点
- 如何根据文件的inode号查找inode数据
- 文件编辑器+1.文件节点接口INode
- inode节点中的三个时间总结:
- JBOSS 开发环境搭建
- ubuntu下为git配置SSH(更新不再需要输入帐号密码)
- 常见排序的java实现
- Git的进阶
- C/C++_log2000_幸运周期
- inode节点查找
- 通过HttpURLConnection获取网页信息
- 【SSH网上商城】框架
- 欢迎使用CSDN-markdown编辑器
- 复选框的全选反选实现(即购物车的复选框实现)
- ssh免密码登录
- 朴素贝叶斯算法
- java中的try,catch,finally用法
- C++ static关键字