From: Liu Bo Date: Thu, 24 Jul 2014 14:48:05 +0000 (+0800) Subject: Btrfs: fix compressed write corruption on enospc X-Git-Tag: upstream/snapshot3+hdmi~1807 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd7c57d3ca1a55a601c9f9e2d3b0fe8be197ea8e;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git Btrfs: fix compressed write corruption on enospc commit ce62003f690dff38d3164a632ec69efa15c32cbf upstream. 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 Tested-By: Martin Steigerwald Signed-off-by: Chris Mason Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d3d4448..c69c763 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -701,6 +701,18 @@ retry: unlock_extent(io_tree, async_extent->start, async_extent->start + async_extent->ram_size - 1); + + /* + * we need to redirty the pages if we decide to + * fallback to uncompressed IO, otherwise we + * will not submit these pages down to lower + * layers. + */ + extent_range_redirty_for_io(inode, + async_extent->start, + async_extent->start + + async_extent->ram_size - 1); + goto retry; } goto out_free;