Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 35597
b: refs/heads/master
c: db37648
h: refs/heads/master
i:
  35595: 3edfe31
v: v3
  • Loading branch information
Nick Piggin authored and Linus Torvalds committed Sep 26, 2006
1 parent 78b263f commit 7141821
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 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: 28e4d965e6131ace1e813e93aebca89ac6b82dc1
refs/heads/master: db37648cd6ce9b828abd6d49aa3d269926ee7b7d
15 changes: 15 additions & 0 deletions trunk/include/linux/pagemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,29 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
}

extern void FASTCALL(__lock_page(struct page *page));
extern void FASTCALL(__lock_page_nosync(struct page *page));
extern void FASTCALL(unlock_page(struct page *page));

/*
* lock_page may only be called if we have the page's inode pinned.
*/
static inline void lock_page(struct page *page)
{
might_sleep();
if (TestSetPageLocked(page))
__lock_page(page);
}

/*
* lock_page_nosync should only be used if we can't pin the page's inode.
* Doesn't play quite so well with block device plugging.
*/
static inline void lock_page_nosync(struct page *page)
{
might_sleep();
if (TestSetPageLocked(page))
__lock_page_nosync(page);
}

/*
* This is exported only for wait_on_page_locked/wait_on_page_writeback.
Expand Down
17 changes: 17 additions & 0 deletions trunk/mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,12 @@ struct page *page_cache_alloc_cold(struct address_space *x)
EXPORT_SYMBOL(page_cache_alloc_cold);
#endif

static int __sleep_on_page_lock(void *word)
{
io_schedule();
return 0;
}

/*
* In order to wait for pages to become available there must be
* waitqueues associated with pages. By using a hash table of
Expand Down Expand Up @@ -577,6 +583,17 @@ void fastcall __lock_page(struct page *page)
}
EXPORT_SYMBOL(__lock_page);

/*
* Variant of lock_page that does not require the caller to hold a reference
* on the page's mapping.
*/
void fastcall __lock_page_nosync(struct page *page)
{
DEFINE_WAIT_BIT(wait, &page->flags, PG_locked);
__wait_on_bit_lock(page_waitqueue(page), &wait, __sleep_on_page_lock,
TASK_UNINTERRUPTIBLE);
}

/**
* find_get_page - find and get a page reference
* @mapping: the address_space to search
Expand Down
2 changes: 1 addition & 1 deletion trunk/mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ int set_page_dirty_lock(struct page *page)
{
int ret;

lock_page(page);
lock_page_nosync(page);
ret = set_page_dirty(page);
unlock_page(page);
return ret;
Expand Down

0 comments on commit 7141821

Please sign in to comment.