posix_fadvise/WILLNEED synchronous on fuse/sshfs instead of async?
While trying to use posix_fadvise(...POSIX_FADVISE_WILLNEED) to implement userspace read-ahead (with a bigger read-ahead window than the kernel default) I found that if the underlying filesystem is fuse/sshfs posix_fadvise is no longer doing asynchronous reads:
strace -tt with mnt/testfile on sshfs and server with very slow upstream (ADSL):
5345 00:00:17.334209 open("mnt/testfile", O_RDONLY|O_LARGEFILE) = 3
5345 00:00:18.011383 _llseek(3, 0, [3544379], SEEK_END) = 0
5345 00:00:18.011626 _llseek(3, 0, [0], SEEK_SET) = 0
5345 00:00:18.012393 fadvise64_64(3, 0, 1048576, POSIX_FADV_WILLNEED) = 0
5345 00:01:02.438097 write(1, "[file] File size is 3544379 byte"..., 34) = 34Note that fadvise takes 40 seconds...
Is this expected behaviour?
I would have expected that fadvise is always asynchronous and I could rely on the call to return almost immediately.
Signature · 1 line
Tobias PGP: http://8ef7ddba.uguu.de
Quoted 7 lines · Tobias Diedrich
While trying to use
posix_fadvise(...POSIX_FADVISE_WILLNEED)to implement userspace read-ahead (with a bigger read-ahead window than the kernel default) I found that if the underlying filesystem is fuse/sshfsposix_fadviseis no longer doing asynchronous reads:strace -tt with mnt/testfile on sshfs and server with very slow upstream (ADSL):
Quoted 8 lines
5345 00:00:17.334209 open("mnt/testfile", O_RDONLY|O_LARGEFILE) = 3 5345 00:00:18.011383 _llseek(3, 0, [3544379], SEEK_END) = 0 5345 00:00:18.011626 _llseek(3, 0, [0], SEEK_SET) = 0 5345 00:00:18.012393 fadvise64_64(3, 0, 1048576, POSIX_FADV_WILLNEED) = 0 5345 00:01:02.438097 write(1, "[file] File size is 3544379 byte"..., 34) = 34Note that fadvise takes 40 seconds...
Is this expected behaviour?
I think this is because fuse limits the number of outstanding requests.
In 2.6.31 you can raise these limits in
/sys/fs/fuse/connections/N/congestion_threshold
/sys/fs/fuse/connections/N/max_background
Thanks,
Miklos