* 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);
}
*/
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);
}
/*
*/
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);
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;
}
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)) {