From: Jens Axboe Date: Sat, 26 Sep 2009 15:34:25 +0000 (+0200) Subject: Make lock_page_async() accept the wait queue X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=81433ee666e5620b534fe50412196b54966f590f;p=linux-block.git Make lock_page_async() accept the wait queue Signed-off-by: Jens Axboe --- diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 59fc8999e9f0..6b55e4cffffb 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -325,17 +325,19 @@ static inline void lock_page_nosync(struct page *page) * lock_page(). If that happens, this helper may also return fatal signals * terminating the wait, even if the page isn't locked yet. */ -static inline int lock_page_async(struct page *page) +static inline int lock_page_async(struct page *page, struct wait_bit_queue *wq) { might_sleep(); if (!trylock_page(page)) { - struct wait_bit_queue *wq; DEFINE_WAIT_BIT(wq_stack, &page->flags, PG_locked); - wq = current->io_wait; if (!wq) wq = &wq_stack; + else { + wq->key.flags = &page->flags; + wq->key.bit_nr = PG_locked; + } return __lock_page_async(page, wq); } @@ -348,12 +350,8 @@ static inline int lock_page_async(struct page *page) */ static inline void lock_page(struct page *page) { - might_sleep(); - - if (!trylock_page(page)) { - int ret = __lock_page_async(page, NULL); - WARN_ON(ret); - } + WARN_ON(current->io_wait); + lock_page_async(page, NULL); } /* diff --git a/mm/filemap.c b/mm/filemap.c index 24124388e8d4..91d24ff03324 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -623,14 +623,10 @@ EXPORT_SYMBOL(end_page_writeback); */ int __lock_page_async(struct page *page, struct wait_bit_queue *wq) { - int (*fn)(void *); + int (*fn)(void *) = sync_page; - if (wq) { - wq->key.flags = &page->flags; - wq->key.bit_nr = PG_locked; + if (!is_sync_wait_bit_queue(wq)) fn = sync_page_killable; - } else - fn = sync_page; return __wait_on_bit_lock(page_waitqueue(page), wq, fn, TASK_UNINTERRUPTIBLE); @@ -1126,7 +1122,7 @@ page_ok: page_not_up_to_date: /* Get exclusive access to the page ... */ - error = lock_page_async(page); + error = lock_page_async(page, current->io_wait); if (unlikely(error)) goto readpage_error; @@ -1157,7 +1153,7 @@ readpage: } if (!PageUptodate(page)) { - error = lock_page_async(page); + error = lock_page_async(page, current->io_wait); if (unlikely(error)) goto readpage_error; if (!PageUptodate(page)) {