QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1496|回复: 0

read code question

[复制链接]
发表于 2003-3-27 01:24:20 | 显示全部楼层 |阅读模式
I read this one in filemap.c. and do not understand it.

static struct page * __find_lock_page_helper(struct address_space *mapping,
                                        unsigned long offset, struct page *hash)
{
struct page *page;

/*
  * We scan the hash list read-only. Addition to and removal from
  * the hash-list needs a held write-lock.
  */
repeat:
page = __find_page_nolock(mapping, offset, hash);
if (page) {
  page_cache_get(page);
  if (TryLockPage(page)) {
   spin_unlock(&pagecache_lock);
   lock_page(page);
   spin_lock(&pagecache_lock);

   /* Has the page been re-allocated while we slept? */
   if (page->mapping != mapping || page->index != offset) {
    UnlockPage(page);
    page_cache_release(page);
    goto repeat;  
   }
}
}
return page;
}

why i need spin_unlock before lock the page, why not lock it directly. after  checking it is reallocated, why i need release it?
can some one explain it? thx
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-6-26 19:08 , Processed in 0.055637 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表