Liu Bo 19fd2df5b1 Btrfs: fix btrfs_ordered_update_i_size to update disk_i_size properly
btrfs_ordered_update_i_size can be called by truncate and endio, but
only endio takes ordered_extent which contains the completed IO.

while truncating down a file, if there are some in-flight IOs,
btrfs_ordered_update_i_size in endio will set disk_i_size to
@orig_offset that is zero.  If truncating-down fails somehow, we try to
recover in memory isize with this zero'd disk_i_size.

Fix it by only updating disk_i_size with @orig_offset when
btrfs_ordered_update_i_size is not called from endio while truncating
down and waiting for in-flight IOs completing their work before recover
in-memory size.

Besides fixing the above issue, add an assertion for last_size to double
check we truncate down to the desired size.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-02-14 15:50:57 +01:00
..
2016-12-22 11:25:24 +00:00
2017-01-14 14:58:29 -06:00
2016-12-25 17:21:23 +01:00
2017-01-31 13:23:09 -05:00
2016-12-25 17:21:22 +01:00
2017-01-14 19:31:40 -05:00
2016-12-05 19:01:16 -05:00
2016-09-27 18:47:38 -04:00
2016-12-14 23:48:11 -05:00
2016-12-03 20:51:35 -05:00
2016-12-16 16:30:49 -05:00
2016-12-05 19:03:49 -05:00
2016-11-30 08:38:07 +01:00
2016-12-25 17:21:22 +01:00