[LTP] [PATCH 1/2] fallocate05: Check that deallocated file range is marked as a hole

Petr Vorel pvorel@suse.cz
Fri Sep 6 10:17:54 CEST 2024


Hi Martin,

> The new lseek(SEEK_HOLE/SEEK_DATA) checks will be useful for diagnosing
> why the final write() check fails with ENOSPC. If the hole doesn't get
> created at all, the lseek() checks will fail.

Thank you!

...
> +	/* Check that the deallocated file range is marked as a hole */
> +	TEST(lseek(fd, 0, SEEK_HOLE));
> +
> +	if (TST_RET == 0) {
> +		tst_res(TPASS, "Test file contains hole at offset 0");
> +	} else if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "lseek(SEEK_HOLE) failed");
> +	} else {
> +		tst_res(TFAIL | TTERRNO,
> +			"Unexpected lseek(SEEK_HOLE) return value %ld",
> +			TST_RET);
> +	}
nit: maybe just using SAFE_LSEEK()?

> +
> +	TEST(lseek(fd, 0, SEEK_DATA));
> +
> +	if (TST_RET == holesize) {
> +		tst_res(TPASS, "Test file data start at offset %ld", TST_RET);
> +	} else if (TST_RET == -1) {
> +		tst_res(TFAIL | TTERRNO, "lseek(SEEK_DATA) failed");
> +	} else {
> +		tst_res(TFAIL | TTERRNO,
> +			"Unexpected lseek(SEEK_DATA) return value %ld",
> +			TST_RET);
> +	}

nit: and here just:

TEST(SAFE_LSEEK(fd, 0, SEEK_DATA));
if (TST_RET == holesize)
	tst_res(TPASS, "Test file data start at offset %ld", TST_RET);

Whatever you choose, LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr


More information about the ltp mailing list