Repository navigation
unexpected behavior on direct_io = True #64
Copy link
Copy link
Open
Labels
Description
I slightly modified example/hello.py, so that it uses direct_io, and I cannot explain the result. With ./test mountpoint, the command cat ./test/hello works fine with direct_io = False, but enters infinite loop when direct_io = True.
The interesting part: compare output of strace -y cat ./test/hello >/dev/null:
direct_io = False
openat(AT_FDCWD</home/mateusz/Downloads>, "./test/hello", O_RDONLY) = 3</home/mateusz/Downloads/test/hello>
newfstatat(3</home/mateusz/Downloads/test/hello>, "", {st_mode=S_IFREG|0444, st_size=1000, ...}, AT_EMPTY_PATH) = 0
fadvise64(3</home/mateusz/Downloads/test/hello>, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5bf4bdb000
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 1000
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 1000) = 1000
read(3</home/mateusz/Downloads/test/hello>, "", 131072) = 0
munmap(0x7f5bf4bdb000, 139264) = 0
close(3</home/mateusz/Downloads/test/hello>) = 0
direct_io = True
openat(AT_FDCWD</home/mateusz/Downloads>, "./test/hello", O_RDONLY) = 3</home/mateusz/Downloads/test/hello>
newfstatat(3</home/mateusz/Downloads/test/hello>, "", {st_mode=S_IFREG|0444, st_size=1000, ...}, AT_EMPTY_PATH) = 0
fadvise64(3</home/mateusz/Downloads/test/hello>, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f60baa38000
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
.... # infinite loop
Ubuntu 22.04
fusermount3 version: 3.10.5
Full reproducer:
hello.py.txt
Reactions are currently unavailable
Activity
bieganski commentedon Feb 26, 2024
i think that the i found the behavior difference varying on
direct_ioswitch state.with
direct_io = False, even if user-definedread()returnsNbytes always, the framework traces number of bytes already passed to user, and seemingly will trim it to at mostst.st_sizeand at some point will return less thanNbytes.with
direct_io = True, thest.st_sizevalue is not taken into consideration, socatprogram enters infinite loop.can someone with better insights tell if I described it correctly?
bieganski commentedon Feb 26, 2024
Speaking about documentation: it is mentioned in
direct_iosection:I can tell however, that for someone like me, who uses
FUSEfirst time, this is the confusing part.direct_ioswitch should be only about performance, and from interface point of view it shouldn't change the functionality. And if it does, I would expect to have a clear warning about that.If however that "side-effect" is somehow obvious, please let me know - it might be just my lack of experience.