SEEK_HOLE and SEEK_DATA does not work on zfs (with test case)
Andriy Gapon
avg at FreeBSD.org
Wed Apr 4 08:38:50 UTC 2012
on 04/04/2012 10:52 Attila Nagy said the following:
> Hi,
>
> I've started to experiment with SEEK_HOLE and SEEK_DATA in python on a recent
> FreeBSD 9-STABLE/amd64 box and it quickly became evident that the program that
> works on Solaris doesn't work on FreeBSD.
> Python itself couldn't cause this, because it correctly issues the lseek, but
> taking the C test program from here:
> https://lkml.org/lkml/2011/4/22/79
> gives the same result (failure).
Please see this PR: http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/164445
If you can't figure out a patch from its contents, then I'll try to provide it
some time later today.
> On a Solaris 10 box I get (the correct result):
> creating file
> Error 0
> fpathconf gives 512, ENXIO is 6
>
> testing at start
> CUR at offset 0, errno 0
> HOLE gives offset 131072, errno 0
> CUR at offset 131072, errno 0
> DATA gives offset 0, errno 0
> CUR at offset 0, errno 0
> HOLE gives offset 131072, errno 0
> CUR at offset 131072, errno 0
>
> testing at end
> end at offset 1048578, errno 0
> HOLE gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> DATA gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> HOLE gives offset 1048578, errno 0
> CUR at offset 1048578, errno 0
> DATA gives offset 1048577, errno 0
> CUR at offset 1048577, errno 0
>
> testing at offset 1
> HOLE gives offset 131072, errno 0
> CUR at offset 131072, errno 0
> DATA gives offset 1, errno 0
> CUR at offset 1, errno 0
>
> testing at offset 200000
> HOLE gives offset 200000, errno 0
> CUR at offset 200000, errno 0
> DATA gives offset 1048576, errno 0
> CUR at offset 1048576, errno 0
>
> On FreeBSD 9-STABLE/amd64 (all HOLE or DATA seeks fail):
> creating file
> No error: 0
> fpathconf gives 512, ENXIO is 6
>
> testing at start
> CUR at offset 0, errno 0
> HOLE gives offset -1, errno 6
> CUR at offset 0, errno 0
> DATA gives offset -1, errno 6
> CUR at offset 0, errno 0
> HOLE gives offset -1, errno 6
> CUR at offset 0, errno 0
>
> testing at end
> end at offset 1048578, errno 0
> HOLE gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> DATA gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> HOLE gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> DATA gives offset -1, errno 6
> CUR at offset 1048578, errno 0
>
> testing at offset 1
> HOLE gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> DATA gives offset -1, errno 6
> CUR at offset 1048578, errno 0
>
> testing at offset 200000
> HOLE gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> DATA gives offset -1, errno 6
> CUR at offset 1048578, errno 0
>
> Interestingly on an older 8.2-PRELEASE (Dec 14 23:12:05 CET 2010 and i386) box
> it works:
> creating file
> No such file or directory
> fpathconf gives 512, ENXIO is 6
>
> testing at start
> CUR at offset 0, errno 0
> HOLE gives offset 131072, errno 0
> CUR at offset 131072, errno 0
> DATA gives offset 0, errno 0
> CUR at offset 0, errno 0
> HOLE gives offset 131072, errno 0
> CUR at offset 131072, errno 0
>
> testing at end
> end at offset 1048578, errno 0
> HOLE gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> DATA gives offset -1, errno 6
> CUR at offset 1048578, errno 0
> HOLE gives offset 1048578, errno 0
> CUR at offset 1048578, errno 0
> DATA gives offset 1048577, errno 0
> CUR at offset 1048577, errno 0
>
> testing at offset 1
> HOLE gives offset 131072, errno 0
> CUR at offset 131072, errno 0
> DATA gives offset 1, errno 0
> CUR at offset 1, errno 0
>
> testing at offset 200000
> HOLE gives offset 200000, errno 0
> CUR at offset 200000, errno 0
> DATA gives offset 1048576, errno 0
> CUR at offset 1048576, errno 0
>
> I don't know whether 32 bit, the OS or the pool version (the only working
> FreeBSD case use a version 13 zpool) cause the malfunction, but this is a major
> issue for anybody who wants to use this documented feature.
--
Andriy Gapon
More information about the freebsd-fs
mailing list