kernels/linux-2.4.0/mm/filemap.c
/*
 * Get the lock to a page atomically.
 */
Get the lock to a page atomically.
Get the lock to a page atomically .
struct page * __find_lock_page (struct address_space *mapping,
				unsigned long offset, struct page **hash)
{
	struct page *page;
repeat:
	spin_lock(&pagecache_lock);
	page = __find_page_nolock(mapping, offset, *hash);
	if (page) {
		page_cache_get(page);
		spin_unlock(&pagecache_lock);
		lock_page(page);
		if (page->mapping)
			return page;
		UnlockPage(page);
		page_cache_release(page);
		goto repeat;
	}
	spin_unlock(&pagecache_lock);
	return NULL;
}
struct page * __find_lock_page ( struct address_space * mapping , unsigned long offset , struct page * * hash ) { struct page * page ; repeat : spin_lock ( & pagecache_lock ) ; page = __find_page_nolock ( mapping , offset , * hash ) ; if ( page ) { page_cache_get ( page ) ; spin_unlock ( & pagecache_lock ) ; lock_page ( page ) ; if ( page -> mapping ) return page ; UnlockPage ( page ) ; page_cache_release ( page ) ; goto repeat ; } spin_unlock ( & pagecache_lock ) ; return NULL ; }
Get the lock to a page atomically.
Get the lock to a page atomically .
/*
	 * We scan the hash list read-only. Addition to and removal from
	 * the hash-list needs a held write-lock.
	 */ /* Is the page still hashed? Ok, good.. */ /* Nope: we raced. Release and try again.. */