fsx: allow zero range operations to cross eof

Currently we are limiting the range for zero range operations to stay
within the i_size boundary. This is not optimal because like this we lose
coverage of the filesystem's zero range implementation, since zero range
operations are allowed to cross the i_size. Fix this by limiting the range
to 'maxfilelen' and not 'file_size', and update the 'file_size' after each
zero range operation if needed.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Filipe Manana
2020-04-20 18:07:38 +01:00
committed by Eryu Guan
parent d9f75cdc8f
commit 15898a13d6
+12 -1
View File
@@ -1244,6 +1244,17 @@ do_zero_range(unsigned offset, unsigned length, int keep_size)
}
memset(good_buf + offset, '\0', length);
if (!keep_size && end_offset > file_size) {
/*
* If there's a gap between the old file size and the offset of
* the zero range operation, fill the gap with zeroes.
*/
if (offset > file_size)
memset(good_buf + file_size, '\0', offset - file_size);
file_size = end_offset;
}
}
#else
@@ -2141,7 +2152,7 @@ have_op:
do_punch_hole(offset, size);
break;
case OP_ZERO_RANGE:
TRIM_OFF_LEN(offset, size, file_size);
TRIM_OFF_LEN(offset, size, maxfilelen);
do_zero_range(offset, size, keep_size);
break;
case OP_COLLAPSE_RANGE: