Commit 8b1763fb authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

[PATCH] misc pagecache cleanups / tweaks

- inline grab_cache_page() in pagemap.h, it's just a simple wrapper
  around find_or_create_page()
- rename (__)remove_inode_page to (__)remove_from_page_cache and
  move them from mm.h and swap.h to pagemap.h because they reverse
  add_to_page_cache and that's where they belong.
parent 28e17277
......@@ -450,7 +450,6 @@ static inline int can_vma_merge(struct vm_area_struct * vma, unsigned long vm_fl
struct zone_t;
/* filemap.c */
extern void remove_inode_page(struct page *);
extern unsigned long page_unuse(struct page *);
extern void truncate_inode_pages(struct address_space *, loff_t);
......
......@@ -42,8 +42,14 @@ extern struct page * find_trylock_page(struct address_space *mapping,
extern struct page * find_or_create_page(struct address_space *mapping,
unsigned long index, unsigned int gfp_mask);
extern struct page * grab_cache_page(struct address_space *mapping,
unsigned long index);
/*
* Returns locked page at given index in given cache, creating it if needed.
*/
static inline struct page *grab_cache_page(struct address_space *mapping, unsigned long index)
{
return find_or_create_page(mapping, index, mapping->gfp_mask);
}
extern struct page * grab_cache_page_nowait(struct address_space *mapping,
unsigned long index);
extern struct page * read_cache_page(struct address_space *mapping,
......@@ -52,6 +58,8 @@ extern struct page * read_cache_page(struct address_space *mapping,
extern int add_to_page_cache(struct page *page,
struct address_space *mapping, unsigned long index);
extern void remove_from_page_cache(struct page *page);
extern void __remove_from_page_cache(struct page *page);
static inline void ___add_to_page_cache(struct page *page,
struct address_space *mapping, unsigned long index)
......
......@@ -133,7 +133,6 @@ extern unsigned long totalhigh_pages;
extern unsigned int nr_free_pages(void);
extern unsigned int nr_free_buffer_pages(void);
extern unsigned int nr_free_pagecache_pages(void);
extern void __remove_inode_page(struct page *);
/* Incomplete types for prototype declarations: */
struct task_struct;
......
......@@ -268,7 +268,7 @@ EXPORT_SYMBOL(poll_freewait);
EXPORT_SYMBOL(ROOT_DEV);
EXPORT_SYMBOL(find_get_page);
EXPORT_SYMBOL(find_lock_page);
EXPORT_SYMBOL(grab_cache_page);
EXPORT_SYMBOL(find_or_create_page);
EXPORT_SYMBOL(grab_cache_page_nowait);
EXPORT_SYMBOL(read_cache_page);
EXPORT_SYMBOL(vfs_readlink);
......
......@@ -68,7 +68,7 @@ spinlock_t pagemap_lru_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
* sure the page is locked and that nobody else uses it - or that usage
* is safe. The caller must hold a write_lock on the mapping's page_lock.
*/
void __remove_inode_page(struct page *page)
void __remove_from_page_cache(struct page *page)
{
struct address_space *mapping = page->mapping;
......@@ -83,7 +83,7 @@ void __remove_inode_page(struct page *page)
dec_page_state(nr_pagecache);
}
void remove_inode_page(struct page *page)
void remove_from_page_cache(struct page *page)
{
struct address_space *mapping = page->mapping;
......@@ -91,7 +91,7 @@ void remove_inode_page(struct page *page)
PAGE_BUG(page);
write_lock(&mapping->page_lock);
__remove_inode_page(page);
__remove_from_page_cache(page);
write_unlock(&mapping->page_lock);
}
......@@ -143,7 +143,7 @@ void invalidate_inode_pages(struct inode * inode)
goto unlock;
__lru_cache_del(page);
__remove_inode_page(page);
__remove_from_page_cache(page);
unlock_page(page);
page_cache_release(page);
continue;
......@@ -186,7 +186,7 @@ static void truncate_complete_page(struct page *page)
ClearPageDirty(page);
ClearPageUptodate(page);
remove_inode_page(page);
remove_from_page_cache(page);
page_cache_release(page);
}
......@@ -808,15 +808,6 @@ struct page *find_or_create_page(struct address_space *mapping,
return page;
}
/*
* Returns locked page at given index in given cache, creating it if needed.
*/
struct page *grab_cache_page(struct address_space *mapping, unsigned long index)
{
return find_or_create_page(mapping, index, mapping->gfp_mask);
}
/*
* Same as grab_cache_page, but do not wait if the page is unavailable.
* This is intended for speculative data generators, where the data can
......
......@@ -95,7 +95,7 @@ void __delete_from_swap_cache(struct page *page)
BUG_ON(!PageSwapCache(page));
BUG_ON(PageWriteback(page));
ClearPageDirty(page);
__remove_inode_page(page);
__remove_from_page_cache(page);
INC_CACHE_INFO(del_total);
}
......@@ -206,7 +206,7 @@ int move_to_swap_cache(struct page *page, swp_entry_t entry)
err = radix_tree_reserve(&swapper_space.page_tree, entry.val, &pslot);
if (!err) {
/* Remove it from the page cache */
__remove_inode_page (page);
__remove_from_page_cache(page);
/* Add it to the swap cache */
*pslot = page;
......
......@@ -288,7 +288,7 @@ shrink_cache(int nr_pages, zone_t *classzone,
/* point of no return */
if (likely(!PageSwapCache(page))) {
__remove_inode_page(page);
__remove_from_page_cache(page);
write_unlock(&mapping->page_lock);
} else {
swp_entry_t swap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment