fsx: fix bug where zero range operations never use the keep size flag
authorFilipe Manana <fdmanana@suse.com>
Fri, 6 Mar 2020 12:35:17 +0000 (12:35 +0000)
committerEryu Guan <guaneryu@gmail.com>
Sun, 8 Mar 2020 15:47:19 +0000 (23:47 +0800)
We are never using the FALLOC_FL_KEEP_SIZE flag for zero range operations
even when we intend to use it. So fix it by setting that flag for the
call to fallocate(2) if the 'keep_size' parameter is true.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
ltp/fsx.c

index 02403720ffd3119790700fd383a9693f7de4ff8a..9d598a4f27a0ea949dec901f9dc3f596e257608b 100644 (file)
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -1200,6 +1200,9 @@ do_zero_range(unsigned offset, unsigned length, int keep_size)
        unsigned end_offset;
        int mode = FALLOC_FL_ZERO_RANGE;
 
+       if (keep_size)
+               mode |= FALLOC_FL_KEEP_SIZE;
+
        if (length == 0) {
                if (!quiet && testcalls > simulatedopcount)
                        prt("skipping zero length zero range\n");