[LTP] [PATCH 1/2] fallocate05: Check that deallocated file range is marked as a hole
Martin Doucha
mdoucha@suse.cz
Fri Sep 6 10:28:07 CEST 2024
On 06. 09. 24 10:17, Petr Vorel wrote:
> 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()?
Definitely no SAFE_LSEEK() here because I want to continue to the second
lseek() even if the first one fails.
>
>> +
>> + 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);
We could use SAFE_LSEEK() here at least until someone decides to add
another sanity check below it. But we still need the "else" branch to
report wrong hole size. I'd say it's slightly better to keep it as is
for the more descriptive error messages.
--
Martin Doucha mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
More information about the ltp
mailing list