inode cache

ArrayTang 2010-03-19 08:35:33
linux kernel 1.0 中__iget 实现如下:

struct inode * __iget(struct super_block * sb, int nr, int crossmntp)
{
static struct wait_queue * update_wait = NULL;
struct inode_hash_entry * h;
struct inode * inode;
struct inode * empty = NULL;

if (!sb)
panic("VFS: iget with sb==NULL");
h = hash(sb->s_dev, nr);
repeat:
for (inode = h->inode; inode ; inode = inode->i_hash_next)
if (inode->i_dev == sb->s_dev && inode->i_ino == nr)
goto found_it;
if (!empty) {
h->updating++;
empty = get_empty_inode();
if (!--h->updating)
wake_up(&update_wait);
if (empty)
goto repeat;
return (NULL);
}
inode = empty;
inode->i_sb = sb;
inode->i_dev = sb->s_dev;
inode->i_ino = nr;
inode->i_flags = sb->s_flags;
put_last_free(inode);
insert_inode_hash(inode);
read_inode(inode);
goto return_it;

found_it:
if (!inode->i_count)
nr_free_inodes--;
inode->i_count++;
wait_on_inode(inode);
if (inode->i_dev != sb->s_dev || inode->i_ino != nr) {
printk("Whee.. inode changed from under us. Tell Linus\n");
iput(inode);
goto repeat;
}
if (crossmntp && inode->i_mount) {
struct inode * tmp = inode->i_mount;
tmp->i_count++;
iput(inode);
inode = tmp;
wait_on_inode(inode);
}
if (empty)
iput(empty);

return_it:
while (h->updating)
sleep_on(&update_wait);
return inode;
}

请问其中的update_wait是什么作用? 如何起作用的? 谢谢~
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ArrayTang 2010-03-21
  • 打赏
  • 举报
回复
谢谢回复,只是我想知道这个update_wait在这里逻辑上起什么作用? 或者说不用这个等待队列会有什么问题?
小魔菇 2010-03-20
  • 打赏
  • 举报
回复
一个等待队列
如果不能立即满足要求 就把它挂在该队列上
如果有资源空闲 就唤醒等待该资源的队列上的东东
hallowwar 2010-03-20
  • 打赏
  • 举报
回复
wake_up(&update_wait);
是个请求队列,wake_up函数对其进行查询,如果非空就执行,否则就继续repeat。
ArrayTang 2010-03-20
  • 打赏
  • 举报
回复
谢谢哦,感觉这些kernel实现的问题,关注的人不多啊
durant 2010-03-20
  • 打赏
  • 举报
回复
快要沉了,帮你顶下
希望有会的人来帮你解答下

4,436

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧