diff options
author | Matthew Wilcox <matthew.r.wilcox@intel.com> | 2014-06-04 19:07:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-04 19:54:02 -0400 |
commit | 57d998456ae8680ed446aa1993f45f4d8a9a5973 (patch) | |
tree | 9e6eef3413adffabf06dc10dafab03c02d21c8be | |
parent | 90768eee4565adb28ea28b4ac5081c676a8fe1f2 (diff) |
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: Matthew 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/mpage.c | 18 | ||||
-rw-r--r-- | include/linux/pagemap.h | 2 | ||||
-rw-r--r-- | mm/filemap.c | 25 |
3 files changed, 28 insertions, 17 deletions
diff --git a/fs/mpage.c b/fs/mpage.c index 4cc9c5d079f7..10da0da73017 100644 --- a/fs/mpage.c +++ b/fs/mpage.c | |||
@@ -48,23 +48,7 @@ static void mpage_end_io(struct bio *bio, int err) | |||
48 | 48 | ||
49 | bio_for_each_segment_all(bv, bio, i) { | 49 | bio_for_each_segment_all(bv, bio, i) { |
50 | struct page *page = bv->bv_page; | 50 | struct page *page = bv->bv_page; |
51 | 51 | page_endio(page, bio_data_dir(bio), err); | |
52 | if (bio_data_dir(bio) == READ) { | ||
53 | if (!err) { | ||
54 | SetPageUptodate(page); | ||
55 | } else { | ||
56 | ClearPageUptodate(page); | ||
57 | SetPageError(page); | ||
58 | } | ||
59 | unlock_page(page); | ||
60 | } else { /* bio_data_dir(bio) == WRITE */ | ||
61 | if (err) { | ||
62 | SetPageError(page); | ||
63 | if (page->mapping) | ||
64 | set_bit(AS_EIO, &page->mapping->flags); | ||
65 | } | ||
66 | end_page_writeback(page); | ||
67 | } | ||
68 | } | 52 | } |
69 | 53 | ||
70 | bio_put(bio); | 54 | bio_put(bio); |
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 45598f1e9aa3..718214c5584e 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h | |||
@@ -425,6 +425,8 @@ static inline void wait_on_page_writeback(struct page *page) | |||
425 | extern void end_page_writeback(struct page *page); | 425 | extern void end_page_writeback(struct page *page); |
426 | void wait_for_stable_page(struct page *page); | 426 | void wait_for_stable_page(struct page *page); |
427 | 427 | ||
428 | void page_endio(struct page *page, int rw, int err); | ||
429 | |||
428 | /* | 430 | /* |
429 | * Add an arbitrary waiter to a page's wait queue | 431 | * Add an arbitrary waiter to a page's wait queue |
430 | */ | 432 | */ |
diff --git a/mm/filemap.c b/mm/filemap.c index 021056c324e6..47d235b357a7 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -764,6 +764,31 @@ void end_page_writeback(struct page *page) | |||
764 | } | 764 | } |
765 | EXPORT_SYMBOL(end_page_writeback); | 765 | EXPORT_SYMBOL(end_page_writeback); |
766 | 766 | ||
767 | /* | ||
768 | * After completing I/O on a page, call this routine to update the page | ||
769 | * flags appropriately | ||
770 | */ | ||
771 | void page_endio(struct page *page, int rw, int err) | ||
772 | { | ||
773 | if (rw == READ) { | ||
774 | if (!err) { | ||
775 | SetPageUptodate(page); | ||
776 | } else { | ||
777 | ClearPageUptodate(page); | ||
778 | SetPageError(page); | ||
779 | } | ||
780 | unlock_page(page); | ||
781 | } else { /* rw == WRITE */ | ||
782 | if (err) { | ||
783 | SetPageError(page); | ||
784 | if (page->mapping) | ||
785 | mapping_set_error(page->mapping, err); | ||
786 | } | ||
787 | end_page_writeback(page); | ||
788 | } | ||
789 | } | ||
790 | EXPORT_SYMBOL_GPL(page_endio); | ||
791 | |||
767 | /** | 792 | /** |
768 | * __lock_page - get a lock on the page, assuming we need to sleep to get it | 793 | * __lock_page - get a lock on the page, assuming we need to sleep to get it |
769 | * @page: the page to lock | 794 | * @page: the page to lock |