diff options
author | Takafumi Kubota <takafumi.kubota1012@sslab.ics.keio.ac.jp> | 2017-02-09 03:24:33 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2017-02-17 06:03:47 -0500 |
commit | fe01aa65385c226d822013b90608b67c485f8dc6 (patch) | |
tree | 2bcc1b1153f87035b1cac8380007010e1564076b | |
parent | 66bbc1c0c0b283600abd187bf8c8c25ab7549307 (diff) |
Btrfs: add another missing end_page_writeback on submit_extent_page failure
If btrfs_bio_alloc fails in submit_extent_page, submit_extent_page returns
without clearing the writeback bit of the failed page.
__extent_writepage_io, that is a caller of submit_extent_page,
does not clear the remaining writeback bit anywhere.
As a result, this will cause the hang at filemap_fdatawait_range,
because it waits the writeback bit to be cleared from the failed page.
So, we have to call end_page_writeback to clear the writeback bit.
For reproducing the hang, we inject a fault like
if (should_failtest()) { // I define should_failtest()
bio = NULL;
}
else {
bio = btrfs_bio_alloc(...);
}
in submit_extent_page.
We should also check whether page has the bit before end_page_writeback,
to avoid the conflict against the other end_page_writeback in bio_endio.
Thus, we add PageWriteback checks not only in __extent_writepage_io,
but also in write_one_eb too, because it misses the check.
Signed-off-by: Takafumi Kubota <takafumi.kubota1012@sslab.ics.keio.ac.jp>
Reviewed-by: Liu Bo <bo.li.liu@oracle.com>
Cc: David Sterba <dsterba@suse.cz>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/extent_io.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4a8b119655d5..9df6ed30de00 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -3437,8 +3437,11 @@ static noinline_for_stack int __extent_writepage_io(struct inode *inode, | |||
3437 | bdev, &epd->bio, max_nr, | 3437 | bdev, &epd->bio, max_nr, |
3438 | end_bio_extent_writepage, | 3438 | end_bio_extent_writepage, |
3439 | 0, 0, 0, false); | 3439 | 0, 0, 0, false); |
3440 | if (ret) | 3440 | if (ret) { |
3441 | SetPageError(page); | 3441 | SetPageError(page); |
3442 | if (PageWriteback(page)) | ||
3443 | end_page_writeback(page); | ||
3444 | } | ||
3442 | 3445 | ||
3443 | cur = cur + iosize; | 3446 | cur = cur + iosize; |
3444 | pg_offset += iosize; | 3447 | pg_offset += iosize; |
@@ -3754,7 +3757,8 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb, | |||
3754 | epd->bio_flags = bio_flags; | 3757 | epd->bio_flags = bio_flags; |
3755 | if (ret) { | 3758 | if (ret) { |
3756 | set_btree_ioerr(p); | 3759 | set_btree_ioerr(p); |
3757 | end_page_writeback(p); | 3760 | if (PageWriteback(p)) |
3761 | end_page_writeback(p); | ||
3758 | if (atomic_sub_and_test(num_pages - i, &eb->io_pages)) | 3762 | if (atomic_sub_and_test(num_pages - i, &eb->io_pages)) |
3759 | end_extent_buffer_writeback(eb); | 3763 | end_extent_buffer_writeback(eb); |
3760 | ret = -EIO; | 3764 | ret = -EIO; |