* [PATCH] Btrfs: fix missing error return if writeback for extent buffer never started
@ 2019-09-11 16:42 fdmanana
2019-09-11 18:43 ` Josef Bacik
2019-09-23 15:31 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: fdmanana @ 2019-09-11 16:42 UTC (permalink / raw)
To: linux-btrfs
From: Filipe Manana <fdmanana@suse.com>
If lock_extent_buffer_for_io() fails, it returns a negative value, but its
caller btree_write_cache_pages() ignores such error. This means that a
call to flush_write_bio(), from lock_extent_buffer_for_io(), might have
failed. We should make btree_write_cache_pages() notice such error values
and stop immediatelly, making sure filemap_fdatawrite_range() returns an
error to the transaction commit path. A failure from flush_write_bio()
should also result in the endio callback end_bio_extent_buffer_writepage()
being invoked, which sets the BTRFS_FS_*_ERR bits appropriately, so that
there's no risk a transaction or log commit doesn't catch a writeback
failure.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/extent_io.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 1ff438fd5bc2..13a683da71d2 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3969,6 +3969,10 @@ int btree_write_cache_pages(struct address_space *mapping,
if (!ret) {
free_extent_buffer(eb);
continue;
+ } else if (ret < 0) {
+ done = 1;
+ free_extent_buffer(eb);
+ break;
}
ret = write_one_eb(eb, wbc, &epd);
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: fix missing error return if writeback for extent buffer never started
2019-09-11 16:42 [PATCH] Btrfs: fix missing error return if writeback for extent buffer never started fdmanana
@ 2019-09-11 18:43 ` Josef Bacik
2019-09-23 15:31 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2019-09-11 18:43 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On Wed, Sep 11, 2019 at 05:42:28PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> If lock_extent_buffer_for_io() fails, it returns a negative value, but its
> caller btree_write_cache_pages() ignores such error. This means that a
> call to flush_write_bio(), from lock_extent_buffer_for_io(), might have
> failed. We should make btree_write_cache_pages() notice such error values
> and stop immediatelly, making sure filemap_fdatawrite_range() returns an
> error to the transaction commit path. A failure from flush_write_bio()
> should also result in the endio callback end_bio_extent_buffer_writepage()
> being invoked, which sets the BTRFS_FS_*_ERR bits appropriately, so that
> there's no risk a transaction or log commit doesn't catch a writeback
> failure.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Btrfs: fix missing error return if writeback for extent buffer never started
2019-09-11 16:42 [PATCH] Btrfs: fix missing error return if writeback for extent buffer never started fdmanana
2019-09-11 18:43 ` Josef Bacik
@ 2019-09-23 15:31 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2019-09-23 15:31 UTC (permalink / raw)
To: fdmanana; +Cc: linux-btrfs
On Wed, Sep 11, 2019 at 05:42:28PM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> If lock_extent_buffer_for_io() fails, it returns a negative value, but its
> caller btree_write_cache_pages() ignores such error. This means that a
> call to flush_write_bio(), from lock_extent_buffer_for_io(), might have
> failed. We should make btree_write_cache_pages() notice such error values
> and stop immediatelly, making sure filemap_fdatawrite_range() returns an
> error to the transaction commit path. A failure from flush_write_bio()
> should also result in the endio callback end_bio_extent_buffer_writepage()
> being invoked, which sets the BTRFS_FS_*_ERR bits appropriately, so that
> there's no risk a transaction or log commit doesn't catch a writeback
> failure.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-09-23 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11 16:42 [PATCH] Btrfs: fix missing error return if writeback for extent buffer never started fdmanana
2019-09-11 18:43 ` Josef Bacik
2019-09-23 15:31 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).