[PATCH 3.16.y-ckt 130/142] ext4: iterate over buffer heads correctly in move_extent_per_page()

From: Luis Henriques
Date: Tue Mar 22 2016 - 06:51:15 EST

3.16.7-ckt26 -stable review patch. If anyone has any objections, please let me know.


From: Eryu Guan <guaneryu@xxxxxxxxx>

commit 6ffe77bad545f4a7c8edd2a4ee797ccfcd894ab4 upstream.

In commit bcff24887d00 ("ext4: don't read blocks from disk after extents
being swapped") bh is not updated correctly in the for loop and wrong
data has been written to disk. generic/324 catches this on sub-page
block size ext4.

Fixes: bcff24887d00 ("ext4: don't read blocks from disk after extentsbeing swapped")
Signed-off-by: Eryu Guan <guaneryu@xxxxxxxxx>
Signed-off-by: Theodore Ts'o <tytso@xxxxxxx>
Signed-off-by: Luis Henriques <luis.henriques@xxxxxxxxxxxxx>
fs/ext4/move_extent.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 146f8cd627b2..2423b0068183 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -1037,6 +1037,7 @@ data_copy:
*err = ext4_get_block(orig_inode, orig_blk_offset + i, bh, 0);
if (*err < 0)
+ bh = bh->b_this_page;
if (!*err)
*err = block_commit_write(pagep[0], from, from + replaced_size);