Commit 57d99845 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by Linus Torvalds

fs/mpage.c: factor page_endio() out of mpage_end_io()

page_endio() takes care of updating all the appropriate page flags once
I/O has finished to a page.  Switch to using mapping_set_error() instead
of setting AS_EIO directly; this will handle thin-provisioned devices
correctly.
Signed-off-by: default avatarMatthew Wilcox <matthew.r.wilcox@intel.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Dheeraj Reddy <dheeraj.reddy@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 90768eee
...@@ -48,23 +48,7 @@ static void mpage_end_io(struct bio *bio, int err) ...@@ -48,23 +48,7 @@ static void mpage_end_io(struct bio *bio, int err)
bio_for_each_segment_all(bv, bio, i) { bio_for_each_segment_all(bv, bio, i) {
struct page *page = bv->bv_page; struct page *page = bv->bv_page;
page_endio(page, bio_data_dir(bio), err);
if (bio_data_dir(bio) == READ) {
if (!err) {
SetPageUptodate(page);
} else {
ClearPageUptodate(page);
SetPageError(page);
}
unlock_page(page);
} else { /* bio_data_dir(bio) == WRITE */
if (err) {
SetPageError(page);
if (page->mapping)
set_bit(AS_EIO, &page->mapping->flags);
}
end_page_writeback(page);
}
} }
bio_put(bio); bio_put(bio);
......
...@@ -425,6 +425,8 @@ static inline void wait_on_page_writeback(struct page *page) ...@@ -425,6 +425,8 @@ static inline void wait_on_page_writeback(struct page *page)
extern void end_page_writeback(struct page *page); extern void end_page_writeback(struct page *page);
void wait_for_stable_page(struct page *page); void wait_for_stable_page(struct page *page);
void page_endio(struct page *page, int rw, int err);
/* /*
* Add an arbitrary waiter to a page's wait queue * Add an arbitrary waiter to a page's wait queue
*/ */
......
...@@ -764,6 +764,31 @@ void end_page_writeback(struct page *page) ...@@ -764,6 +764,31 @@ void end_page_writeback(struct page *page)
} }
EXPORT_SYMBOL(end_page_writeback); EXPORT_SYMBOL(end_page_writeback);
/*
* After completing I/O on a page, call this routine to update the page
* flags appropriately
*/
void page_endio(struct page *page, int rw, int err)
{
if (rw == READ) {
if (!err) {
SetPageUptodate(page);
} else {
ClearPageUptodate(page);
SetPageError(page);
}
unlock_page(page);
} else { /* rw == WRITE */
if (err) {
SetPageError(page);
if (page->mapping)
mapping_set_error(page->mapping, err);
}
end_page_writeback(page);
}
}
EXPORT_SYMBOL_GPL(page_endio);
/** /**
* __lock_page - get a lock on the page, assuming we need to sleep to get it * __lock_page - get a lock on the page, assuming we need to sleep to get it
* @page: the page to lock * @page: the page to lock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment