btrfs-progs: check: punch_extent_hole in lowmem
authorSu Yue <suy.fnst@cn.fujitsu.com>
Tue, 29 Aug 2017 03:33:23 +0000 (11:33 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 Oct 2017 18:33:00 +0000 (20:33 +0200)
commita47604de3ee0ecbf79ce9d3fd271562177777ec8
treeb01292bb644bc809200c88b76bf462deaf402a12
parent3cfd3f608c9f4fbe5dbeef2636de77a8a8ccbae3
btrfs-progs: check: punch_extent_hole in lowmem

While checking file extents, there are two errors that may occur:

1) There is one hole between the last extent end and beginning of the
   current extent but no-holes is disabled.

2) No-holes is disabled, one file's nbytes equals 0 but isize is not 0.

Those both mean the file may have lost some extents.
To avoid btrfsck's error message, fix it by introducing function
'punch_extent_hole' to punch holes.

For case 1, punch a hole extent whose length is
  (current extent begin - last extent end)
while checking one extent.

For case 2, punch a hole extent whose length is
  (file isize - actual file size)
after traversing one entire file.

Then repair_inode_nbytes will set the nbytes to isize.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-check.c