Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 165733
b: refs/heads/master
c: 83f7866
h: refs/heads/master
i:
  165731: 9ba918f
v: v3
  • Loading branch information
Wu Fengguang authored and Andi Kleen committed Sep 16, 2009
1 parent a7e3172 commit 04fd0f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 750b4987b0cd4d408e54cb83a80a067cbe690feb
refs/heads/master: 83f786680aec8d030184f7ced1a0a3dd8ac81764
2 changes: 2 additions & 0 deletions trunk/include/linux/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ extern int vmtruncate_range(struct inode * inode, loff_t offset, loff_t end);

int truncate_inode_page(struct address_space *mapping, struct page *page);

int invalidate_inode_page(struct page *page);

#ifdef CONFIG_MMU
extern int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
unsigned long address, unsigned int flags);
Expand Down
26 changes: 20 additions & 6 deletions trunk/mm/truncate.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,24 @@ int truncate_inode_page(struct address_space *mapping, struct page *page)
return truncate_complete_page(mapping, page);
}

/*
* Safely invalidate one page from its pagecache mapping.
* It only drops clean, unused pages. The page must be locked.
*
* Returns 1 if the page is successfully invalidated, otherwise 0.
*/
int invalidate_inode_page(struct page *page)
{
struct address_space *mapping = page_mapping(page);
if (!mapping)
return 0;
if (PageDirty(page) || PageWriteback(page))
return 0;
if (page_mapped(page))
return 0;
return invalidate_complete_page(mapping, page);
}

/**
* truncate_inode_pages - truncate range of pages specified by start & end byte offsets
* @mapping: mapping to truncate
Expand Down Expand Up @@ -312,12 +330,8 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
if (lock_failed)
continue;

if (PageDirty(page) || PageWriteback(page))
goto unlock;
if (page_mapped(page))
goto unlock;
ret += invalidate_complete_page(mapping, page);
unlock:
ret += invalidate_inode_page(page);

unlock_page(page);
if (next > end)
break;
Expand Down

0 comments on commit 04fd0f3

Please sign in to comment.