Skip to content

Commit ce62003

Browse files
Liu Bomasoncl
authored andcommitted
Btrfs: fix compressed write corruption on enospc
When failing to allocate space for the whole compressed extent, we'll fallback to uncompressed IO, but we've forgotten to redirty the pages which belong to this compressed extent, and these 'clean' pages will simply skip 'submit' part and go to endio directly, at last we got data corruption as we write nothing. Signed-off-by: Liu Bo <[email protected]> Tested-By: Martin Steigerwald <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent f90e579 commit ce62003

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

fs/btrfs/inode.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,18 @@ static noinline int submit_compressed_extents(struct inode *inode,
709709
unlock_extent(io_tree, async_extent->start,
710710
async_extent->start +
711711
async_extent->ram_size - 1);
712+
713+
/*
714+
* we need to redirty the pages if we decide to
715+
* fallback to uncompressed IO, otherwise we
716+
* will not submit these pages down to lower
717+
* layers.
718+
*/
719+
extent_range_redirty_for_io(inode,
720+
async_extent->start,
721+
async_extent->start +
722+
async_extent->ram_size - 1);
723+
712724
goto retry;
713725
}
714726
goto out_free;

0 commit comments

Comments
 (0)