From: Jens Axboe Date: Sat, 26 Sep 2009 15:33:20 +0000 (+0200) Subject: mm: get rid of __lock_page() X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=0dea363537c69d23ddcbe9d71db9be19a90e736e;p=linux-block.git mm: get rid of __lock_page() Just make lock_page() use __lock_page_async() Signed-off-by: Jens Axboe --- diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index b1a73cc1f23f..59fc8999e9f0 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -287,7 +287,6 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma, return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT); } -extern void __lock_page(struct page *page); extern void __lock_page_nosync(struct page *page); extern int __lock_page_async(struct page *page, struct wait_bit_queue *); extern void unlock_page(struct page *page); @@ -307,16 +306,6 @@ static inline int trylock_page(struct page *page) return (likely(!test_and_set_bit_lock(PG_locked, &page->flags))); } -/* - * 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 (!trylock_page(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. @@ -353,7 +342,20 @@ static inline int lock_page_async(struct page *page) return 0; } - + +/* + * 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 (!trylock_page(page)) { + int ret = __lock_page_async(page, NULL); + WARN_ON(ret); + } +} + /* * This is exported only for wait_on_page_locked/wait_on_page_writeback. * Never use this directly! diff --git a/mm/filemap.c b/mm/filemap.c index 50a494f3ee86..24124388e8d4 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -613,7 +613,7 @@ void end_page_writeback(struct page *page) EXPORT_SYMBOL(end_page_writeback); /** - * __lock_page - get a lock on the page, assuming we need to sleep to get it + * __lock_page_async - get a lock on the page, assuming we need to sleep to get it * @page: the page to lock * * Ugly. Running sync_page() in state TASK_UNINTERRUPTIBLE is scary. If some @@ -621,23 +621,18 @@ EXPORT_SYMBOL(end_page_writeback); * chances are that on the second loop, the block layer's plug list is empty, * so sync_page() will then return in state TASK_UNINTERRUPTIBLE. */ -void __lock_page(struct page *page) -{ - DEFINE_WAIT_BIT(wait, &page->flags, PG_locked); - - __wait_on_bit_lock(page_waitqueue(page), &wait, sync_page, - TASK_UNINTERRUPTIBLE); -} -EXPORT_SYMBOL(__lock_page); - int __lock_page_async(struct page *page, struct wait_bit_queue *wq) { + int (*fn)(void *); + if (wq) { wq->key.flags = &page->flags; wq->key.bit_nr = PG_locked; - } + fn = sync_page_killable; + } else + fn = sync_page; - return __wait_on_bit_lock(page_waitqueue(page), wq, sync_page_killable, + return __wait_on_bit_lock(page_waitqueue(page), wq, fn, TASK_UNINTERRUPTIBLE); } EXPORT_SYMBOL(__lock_page_async);