aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/extent_io.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 3955e475ceec..fa31c8d2c095 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3278,6 +3278,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
3278 end - cur + 1, 1); 3278 end - cur + 1, 1);
3279 if (IS_ERR_OR_NULL(em)) { 3279 if (IS_ERR_OR_NULL(em)) {
3280 SetPageError(page); 3280 SetPageError(page);
3281 ret = PTR_ERR_OR_ZERO(em);
3281 break; 3282 break;
3282 } 3283 }
3283 3284
@@ -3364,13 +3365,17 @@ done:
3364 set_page_writeback(page); 3365 set_page_writeback(page);
3365 end_page_writeback(page); 3366 end_page_writeback(page);
3366 } 3367 }
3368 if (PageError(page)) {
3369 ret = ret < 0 ? ret : -EIO;
3370 end_extent_writepage(page, ret, start, page_end);
3371 }
3367 unlock_page(page); 3372 unlock_page(page);
3368 3373
3369done_unlocked: 3374done_unlocked:
3370 3375
3371 /* drop our reference on any cached states */ 3376 /* drop our reference on any cached states */
3372 free_extent_state(cached_state); 3377 free_extent_state(cached_state);
3373 return 0; 3378 return ret;
3374} 3379}
3375 3380
3376static int eb_wait(void *word) 3381static int eb_wait(void *word)
@@ -3690,6 +3695,7 @@ static int extent_write_cache_pages(struct extent_io_tree *tree,
3690 struct inode *inode = mapping->host; 3695 struct inode *inode = mapping->host;
3691 int ret = 0; 3696 int ret = 0;
3692 int done = 0; 3697 int done = 0;
3698 int err = 0;
3693 int nr_to_write_done = 0; 3699 int nr_to_write_done = 0;
3694 struct pagevec pvec; 3700 struct pagevec pvec;
3695 int nr_pages; 3701 int nr_pages;
@@ -3776,8 +3782,8 @@ retry:
3776 unlock_page(page); 3782 unlock_page(page);
3777 ret = 0; 3783 ret = 0;
3778 } 3784 }
3779 if (ret) 3785 if (!err && ret < 0)
3780 done = 1; 3786 err = ret;
3781 3787
3782 /* 3788 /*
3783 * the filesystem may choose to bump up nr_to_write. 3789 * the filesystem may choose to bump up nr_to_write.
@@ -3789,7 +3795,7 @@ retry:
3789 pagevec_release(&pvec); 3795 pagevec_release(&pvec);
3790 cond_resched(); 3796 cond_resched();
3791 } 3797 }
3792 if (!scanned && !done) { 3798 if (!scanned && !done && !err) {
3793 /* 3799 /*
3794 * We hit the last page and there is more work to be done: wrap 3800 * We hit the last page and there is more work to be done: wrap
3795 * back to the start of the file 3801 * back to the start of the file
@@ -3799,7 +3805,7 @@ retry:
3799 goto retry; 3805 goto retry;
3800 } 3806 }
3801 btrfs_add_delayed_iput(inode); 3807 btrfs_add_delayed_iput(inode);
3802 return ret; 3808 return err;
3803} 3809}
3804 3810
3805static void flush_epd_write_bio(struct extent_page_data *epd) 3811static void flush_epd_write_bio(struct extent_page_data *epd)