return error;
}
-static struct page *
-generic_file_buffered_read_pagenotuptodate(struct kiocb *iocb,
- struct file *filp,
- struct iov_iter *iter,
- struct page *page,
- loff_t pos, loff_t count)
+static int generic_file_buffered_read_pagenotuptodate(struct kiocb *iocb,
+ struct iov_iter *iter, struct page *page, loff_t pos,
+ loff_t count)
{
- struct address_space *mapping = filp->f_mapping;
- struct inode *inode = mapping->host;
+ struct address_space *mapping = iocb->ki_filp->f_mapping;
int error;
/*
} else {
error = wait_on_page_locked_killable(page);
}
- if (unlikely(error)) {
- put_page(page);
- return ERR_PTR(error);
- }
+ if (unlikely(error))
+ goto put_page;
+
if (PageUptodate(page))
- return page;
+ return 0;
- if (inode->i_blkbits == PAGE_SHIFT ||
- !mapping->a_ops->is_partially_uptodate)
+ if (mapping->host->i_blkbits == PAGE_SHIFT ||
+ !mapping->a_ops->is_partially_uptodate)
goto page_not_up_to_date;
/* pipes can't handle partially uptodate pages */
if (unlikely(iov_iter_is_pipe(iter)))
if (!mapping->a_ops->is_partially_uptodate(page,
pos & ~PAGE_MASK, count))
goto page_not_up_to_date_locked;
+
+unlock_page:
unlock_page(page);
- return page;
+ return 0;
page_not_up_to_date:
/* Get exclusive access to the page ... */
error = lock_page_for_iocb(iocb, page);
- if (unlikely(error)) {
- put_page(page);
- return ERR_PTR(error);
- }
+ if (unlikely(error))
+ goto put_page;
page_not_up_to_date_locked:
/* Did it get truncated before we got the lock? */
if (!page->mapping) {
unlock_page(page);
- put_page(page);
- return NULL;
+ error = AOP_TRUNCATED_PAGE;
+ goto put_page;
}
/* Did somebody else fill it already? */
- if (PageUptodate(page)) {
- unlock_page(page);
- return page;
- }
+ if (PageUptodate(page))
+ goto unlock_page;
+ return filemap_readpage(iocb, page);
- error = filemap_readpage(iocb, page);
- if (error) {
- if (error == AOP_TRUNCATED_PAGE)
- return NULL;
- return ERR_PTR(error);
- }
- return page;
+put_page:
+ put_page(page);
+ return error;
}
static struct page *
break;
}
- page = generic_file_buffered_read_pagenotuptodate(iocb,
- filp, iter, page, pg_pos, pg_count);
- if (IS_ERR_OR_NULL(page)) {
+ err = generic_file_buffered_read_pagenotuptodate(iocb,
+ iter, page, pg_pos, pg_count);
+ if (err) {
+ if (err == AOP_TRUNCATED_PAGE)
+ err = 0;
for (j = i + 1; j < nr_got; j++)
put_page(pages[j]);
nr_got = i;
- err = PTR_ERR_OR_ZERO(page);
break;
}
}