mm: get rid of __lock_page()
authorJens Axboe <jens.axboe@oracle.com>
Sat, 26 Sep 2009 15:33:20 +0000 (17:33 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Sat, 26 Sep 2009 15:33:20 +0000 (17:33 +0200)
Just make lock_page() use __lock_page_async()

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
include/linux/pagemap.h
mm/filemap.c

index b1a73cc1f23fd7f8141612b447ca6e4f75077a27..59fc8999e9f05921db29f10a8a9c86dfdd6b2a12 100644 (file)
@@ -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!
index 50a494f3ee86e1396c94cfe76ed3a3a66f44b195..24124388e8d4c03e4610098234a317e6755eb923 100644 (file)
@@ -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);