Mount: write: Bad file descriptor with FileInfoTimeout=-1

Continuing the discussion from VFS is slow when reading in small (8 bytes) chunks:

@ncw i m hurry to convey that we encountered error while writing files with enabled kernel space read ahead (-o FileInfoTimeout=-1) for rclone mounted disk. I think it make sense for hurry as you noted that you would make kernel read ahead enabled by default in next rclone release but i need some time to prepare complete case description.

In simple, python is known to be affected when copying files to virtual file system with something like this:

with open(physical_path, 'rb') as source:
    with open(rclone_path, 'wb') as dest:
        while True:
            buf =*1024)
            if not buf:

It raises OSError: [Errno 9] Bad file descriptor at some point.

System copy seems to be not affected with this issue.

Here is case description, updated on rclone master and run with kernel read ahead

$ git pull
Already up to date.

kalem@DESKTOP-R6MR0O4 MINGW64 ~/Work/dev/thirdparty/rclone (master)
$ git show --stat
commit 11eeaaf792776b598f80e1416f5c9629840e16d8 (HEAD -> master, origin/master, origin/HEAD)
Author: eNV25 <>
Date:   Wed Aug 30 15:29:46 2023 +0200

    cmd/ncdu: fix add keybinding to rescan filesystem

 cmd/ncdu/ncdu.go | 1 +
 1 file changed, 1 insertion(+)

kalem@DESKTOP-R6MR0O4 MINGW64 ~/dev/thirdparty/rclone (master)
$ CPATH="C:\\Program Files\\WinFsp\\inc\\fuse;C:\\Program Files (x86)\\WinFsp\\inc\\fuse" go run -tags cmount rclone.go mount :local:f: x: --vfs-cache-mode=full -o FileInfoTimeout=-1
The service rclone has been started.

cause simple file copy python program to fail:

kalem@DESKTOP-R6MR0O4 MINGW64 ~/Work/dev/thirdparty/rclone (master)
$ python <<EOF
s = open('C:\\\\Users\\\\kalem\\\\Desktop\\\\image.png', 'rb')
d = open('x:\\\\Temp\\\\test.png', 'wb')
while True:
  buf =*1024)
  if not buf:
Traceback (most recent call last):
  File "<stdin>", line 7, in <module>
OSError: [Errno 9] Bad file descriptor

without -o FileInfoTimeout=-1 or with above zero values it runs fine but read ahead should not be enabled.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.