-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properly detect failing fallocate #79
Comments
Can you provide a stand-alone test case that someone could run on an opensolaris vm or something? |
I can confirm that fallocate will fail on ZFS on Solaris 11.1. It seems to work fine in Solaris 11.3 with ZFS, though. try:
import ctypes
import ctypes.util
CAN_FALLOCATE = True
except ImportError:
CAN_FALLOCATE = False
fallocate = None
if CAN_FALLOCATE:
libc_name = ctypes.util.find_library('c')
libc = ctypes.CDLL(libc_name)
c_off64_t = ctypes.c_int64
c_off_t = ctypes.c_int
try:
_fallocate = libc.posix_fallocate64
_fallocate.restype = ctypes.c_int
_fallocate.argtypes = [ctypes.c_int, c_off64_t, c_off64_t]
except AttributeError:
try:
_fallocate = libc.posix_fallocate
_fallocate.restype = ctypes.c_int
_fallocate.argtypes = [ctypes.c_int, c_off_t, c_off_t]
except AttributeError:
CAN_FALLOCATE = False
if CAN_FALLOCATE:
def _py_fallocate(fd, offset, len_):
res = _fallocate(fd.fileno(), offset, len_)
if res != 0:
raise IOError(res, 'fallocate')
fallocate = _py_fallocate
del libc
del libc_name
# The actual test
fd = open("test", "w")
fallocate(fd, 0, 4096) From the posix_fallocate man page on Solaris 11.1:
The same comment is in the Solaris 11.2 man page. |
As the fallocate support is per filesystem I don't see how you could detect if fallocate is supported in advance. One solution could be to try to use fallocate, and if EINVAL is returned (thrown) then resort to using non-fallocate methods. It's perhaps not the most elegant solution. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The check for CAN_FALLOCATE in whisper.py assumes that if it can import ctypes.util it can fallocate. This assumption is not all the time valid, since on most solaris based operating systems running ZFS will fail. I believe the assumption is not correct.
The text was updated successfully, but these errors were encountered: