|
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 |
|