Skip to content

rclone mount do not handle errors for write operations on windows #5465

Open

Description

@kalemas

The associated forum post URL from https://forum.rclone.org

https://forum.rclone.org/t/rclone-mount-synchonous-write-transaction/23771

What is the problem you are having with rclone?

Having mount on windows does not report any error when writing files, so either destination local filesystem is readonly or remote transfer fails, rclone does not report an error on file close. That result in false writing operations and unexpected missed files after unmount/mounting a drive/folder.

there is also thread about this winfsp/winfsp#365 on WinFSP tracker, to summarize, on Windows after successful write, error code could not be reported in Close/Flush/Release operations.

What is your rclone version (output from rclone version)

1.52, 1.55.1

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Windows 10 x64 version 20H2

Which cloud storage system are you using? (e.g. Google Drive)

local, webdav, s3

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

log sample (one of them)
rclone.log

Activity

  1. added this to the Known Problem milestone on Jul 20, 2021
  2. ncw commented on Jul 20, 2021

    @ncw
    Member

    You wrote on the forum

    I think it would be solved by doing sync write and report the error (as a platform specifics or as command line parameter).

    When do you mean doing the sync write? The choices are

    • Write - I don't think we know when the file is finished do we? So I don't see how we could use this
    • Flush - this is what we are doing already but Windows ignores the return code
    • Release - Linux ignores the return code of this

    i attempted to just remove goroutine for Rcat call and it caused deadlock, so it look like i need general guideline to make a PR to solve this.

    Can you show the code you did so far and I can comment?

  3. kalemas commented on Jul 20, 2021

    @kalemas
    Author

    yes, Flush and Release are NOT candidates here, i think we could just avoid buffering and pass data right on destination during handling write operation, this would dramatically affect performance but some scenarios may require guarantee of data transfer. I just would like to see of how that would work. There would be chucked write so multiple operations would be called for single file, but some remotes support chunked upload so maybe that will work fine? What do you think?

    My attempt does not worth your attention:

    diff --git a/vfs/write.go b/vfs/write.go
    index 4f0590312..0b332fb60 100644
    --- a/vfs/write.go
    +++ b/vfs/write.go
    @@ -66,7 +66,7 @@ func (fh *WriteFileHandle) openPending() (err error) {
            pipeReader, fh.pipeWriter = io.Pipe()
    -       go func() {
    +       func() {
                    // NB Rcat deals with Stats.Transferring, etc.
                    o, err := operations.Rcat(context.TODO(), fh.file.Fs(), fh.remote, pipeReader, time.Now())

    so before diving into i decided to discuss any possible scenario of how that would be solved.

  4. ncw commented on Jul 27, 2021

    @ncw
    Member

    i think we could just avoid buffering and pass data right on destination during handling write operation

    Did you try with a much larger file (say 1 GB) which is definitely larger than the buffers? That would show if your idea will work or not.

  5. kalemas commented on Jul 28, 2021

    @kalemas
    Author

    Its 1.1GB, but small file still succeeds.
    rclone.log
    rclone.txt

  6. ncw commented on Jul 28, 2021

    @ncw
    Member

    From the log

    Rclone returned an error on the Write call here

    2021/07/28 12:09:41 ERROR : Movie.(480p).(pk).m4v: WriteFileHandle: Truncate: Can't change size without --vfs-cache-mode >= writes
    ...
    2021/07/28 12:09:42 DEBUG : /Movie.(480p).(pk).m4v: >Write: n=-5
    

    Which turned into this request could not be performed because of an I/O device error.

    You'll need to copy it using something which doesn't try to truncate the file. You should be able to use rclone copy for this instead of copy.

  7. kalemas commented on Aug 17, 2021

    @kalemas
    Author

    @ncw could you point me the options to rclone copy as it look like there is still i\o error on lower level. But i cant find Truncate in the log file now
    rclone.log

    image
    file is 65MB and it appear on destination fs so i m not sure if we got desired result.

    Mounting writeable source result in success for same command.

  8. ncw commented on Aug 19, 2021

    @ncw
    Member

    These are the problem lines from the log. The file fails when it is being written.

    __debug_bin[TID=229c]: FFFFC405EFAA3450: >>Write 0000000000000000:0000022A1F058430, Address=0000022A46310000, Offset=0:0, Length=4096, Key=0
    2021/08/18 01:14:34 DEBUG : /cefpython3-66.1-py2.py3-none-win32.whl.zip: Getattr: fh=0x0
    2021/08/18 01:14:34 DEBUG : /cefpython3-66.1-py2.py3-none-win32.whl.zip: >Getattr: errc=0
    2021/08/18 01:14:34 DEBUG : /cefpython3-66.1-py2.py3-none-win32.whl.zip: Write: ofst=0, fh=0x0
    2021/08/18 01:14:34 DEBUG : : Added virtual directory entry vAddFile: "cefpython3-66.1-py2.py3-none-win32.whl.zip"
    2021/08/18 01:14:34 ERROR : cefpython3-66.1-py2.py3-none-win32.whl.zip: WriteFileHandle.New Rcat failed: The system cannot find the file specified.
    2021/08/18 01:14:34 ERROR : cefpython3-66.1-py2.py3-none-win32.whl.zip: WriteFileHandle.Write error: io: read/write on closed pipe
    2021/08/18 01:14:34 ERROR : IO error: io: read/write on closed pipe
    2021/08/18 01:14:34 DEBUG : /cefpython3-66.1-py2.py3-none-win32.whl.zip: >Write: n=-5
    __debug_bin[TID=229c]: FFFFC405EFAA3450: <<Write IoStatus=c0000185[0]
    

    This gets returned as an IO Error.

    file is 65MB and it appear on destination fs so i m not sure if we got desired result.

    On the destination it appears to be 0 bytes according to your image?

    image

  9. kalemas commented on Aug 19, 2021

    @kalemas
    Author

    The file fails when it is being written.

    it sounds like what we are looking for, isn't it?

    On the destination it appears to be 0 bytes according to your image?

    Yes, i could check, but file may disappear if i refresh Explorer.

  10. kalemas commented on Aug 20, 2021

    @kalemas
    Author

    Nope it does not disappear and sometimes there is non zero size on destination:

    kalem@DESKTOP-R6MR0O4 MINGW64 ~/Downloads/rclone-v1.55.1-windows-amd64
    $ du -h /x/cefpython3-66.1-py2.py3-none-win32.whl.zip
    du: cannot access '/x/cefpython3-66.1-py2.py3-none-win32.whl.zip': No such file or directory
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/Downloads/rclone-v1.55.1-windows-amd64
    $ ./rclone.exe copy ../cefpython3-66.1-py2.py3-none-win32.whl.zip /x/
    2021/08/20 12:36:01 NOTICE: Config file "C:\\Users\\kalem\\.config\\rclone\\rclone.conf" not found - using defaults
    2021/08/20 12:36:01 NOTICE: cefpython3-66.1-py2.py3-none-win32.whl.zip: Removing partially written file on error: write \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:01 ERROR : cefpython3-66.1-py2.py3-none-win32.whl.zip: Failed to remove partially written file: remove \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:01 ERROR : cefpython3-66.1-py2.py3-none-win32.whl.zip: Failed to copy: write \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:01 ERROR : Attempt 1/3 failed with 1 errors and: write \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:01 ERROR : Attempt 2/3 failed with 1 errors and: CreateFile \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:01 ERROR : Attempt 3/3 failed with 1 errors and: CreateFile \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:01 Failed to copy: CreateFile \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/Downloads/rclone-v1.55.1-windows-amd64
    $ du -h /x/cefpython3-66.1-py2.py3-none-win32.whl.zip
    12K     /x/cefpython3-66.1-py2.py3-none-win32.whl.zip
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/Downloads/rclone-v1.55.1-windows-amd64
    $ du -h ../cefpython3-66.1-py2.py3-none-win32.whl.zip
    63M     ../cefpython3-66.1-py2.py3-none-win32.whl.zip
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/Downloads/rclone-v1.55.1-windows-amd64
    $ ./rclone.exe copy ../cefpython3-66.1-py2.py3-none-win32.whl.zip /x/
    2021/08/20 12:36:24 NOTICE: Config file "C:\\Users\\kalem\\.config\\rclone\\rclone.conf" not found - using defaults
    2021/08/20 12:36:24 ERROR : Attempt 1/3 failed with 1 errors and: CreateFile \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:24 ERROR : Attempt 2/3 failed with 1 errors and: CreateFile \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:24 ERROR : Attempt 3/3 failed with 1 errors and: CreateFile \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    2021/08/20 12:36:24 Failed to copy: CreateFile \\?\X:\cefpython3-66.1-py2.py3-none-win32.whl.zip: The request could not be performed because of an I/O device error.
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/Downloads/rclone-v1.55.1-windows-amd64
    $ du -h /x/cefpython3-66.1-py2.py3-none-win32.whl.zip
    12K     /x/cefpython3-66.1-py2.py3-none-win32.whl.zip
  11. ncw commented on Aug 20, 2021

    @ncw
    Member

    The file fails when it is being written.

    it sounds like what we are looking for, isn't it?

    Yes!

    On the destination it appears to be 0 bytes according to your image?

    Yes, i could check, but file may disappear if i refresh Explorer.

    Nope it does not disappear and sometimes there is non zero size on destination:

    I don't think this is rclone's fault. Rclone reported the error correctly - the fact that part of the file got written or not is down to the OS isn't it?

  12. kalemas commented on Nov 23, 2021

    @kalemas
    Author

    i would agree that error is reported but there are two issues still:

    1. error is not always reported for small files:
    kalem@DESKTOP-R6MR0O4 MINGW64 /f/Downloads/rclone-v1.57.0-windows-amd64
    $ ./rclone.exe mount :local:f:/ x: --streaming-upload-cutoff=0 -v &
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/OneDrive/Work/home/dev/my/rclone (master)
    $ while true; do echo 1 ; done | dd of=/x/test.txt count=10
    dd: writing to '/x/test.txt': Input/output error
    1+0 records in
    0+0 records out
    0 bytes copied, 0,0071953 s, 0,0 kB/s
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/OneDrive/Work/home/dev/my/rclone (master)
    $ while true; do echo 1 ; done | dd of=/x/test.txt count=10
    10+0 records in
    10+0 records out
    5120 bytes (5,1 kB, 5,0 KiB) copied, 0,0067603 s, 757 kB/s
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/OneDrive/Work/home/dev/my/rclone (master)
    $ cat /x/test.txt 
    cat: /x/test.txt: Input/output error
    
    1. and error is not reported when write on remote:
    $ ./rclone.exe serve webdav /f/
    $ ./rclone.exe mount :webdav: x: --streaming-upload-cutoff=0 -v --webdav-url=http://localhost:8080/
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/OneDrive/Work/home/dev/my/rclone (master)
    $ cat /dev/random | dd of=/x/test.txt count=100 bs=1024
    100+0 records in
    100+0 records out
    102400 bytes (102 kB, 100 KiB) copied, 0,0158271 s, 6,5 MB/s
    
    kalem@DESKTOP-R6MR0O4 MINGW64 ~/OneDrive/Work/home/dev/my/rclone (master)
    $ ls /x/test.txt -l
    -rw-r--r-- 1 kalem 197609 102400 ноя 23 23:54 /x/test.txt
    
  13. kalemas commented on Nov 23, 2021

    @kalemas
    Author

    If Bill can't come up with a fix for WinFSP then I don't think I can fix it in rclone unless you have any brilliant ideas @kalemas ?

    @ncw if i got correctly, last research confirmed that it is possible to perform write synchronous so error would be reported in write.

  14. ncw commented on Nov 25, 2021

    @ncw
    Member

    If I try your first example in Linux, I always get an error back from dd. However exactly which error changes.

    It can be

    dd: writing to '/mnt/tmp/test.txt': Input/output error
    dd: closing output file '/mnt/tmp/test.txt': Input/output error
    

    or

    dd: closing output file '/mnt/tmp/test.txt': Input/output error
    

    Windows will never report the error on closing file (see winfsp/winfsp#365 (comment) for why). So some of the time we will never get an error.

    I can't solve this. You'll see an ERROR in the rclone log which rclone passes to the OS but the OS never gives it to the dd application.

    However if you add --buffer-size=0 then you should get that synchronous error report on the write so I think Windows should always return the error.

    So this

    rclone mount /tmp/unwritable /mnt/tmp --streaming-upload-cutoff=0 --buffer-size=0 -vv
    

    Always gives

    dd: writing to '/mnt/tmp/test.txt': Input/output error
    dd: closing output file '/mnt/tmp/test.txt': Input/output error
    

    Which I think Windows will report as

    dd: writing to '/mnt/tmp/test.txt': Input/output error
    
  15. kalemas commented on Nov 25, 2021

    @kalemas
    Author

    Confirm, with --buffer-size=0 i can not write a byte on unwriteable destination, so there is still only point 2:

    kalem@DESKTOP-R6MR0O4 MINGW64 /f/Downloads/rclone-v1.57.0-windows-amd64
    > ./rclone.exe serve webdav /f/ &
    [1] 2059
    
    2021/11/25 22:30:23 NOTICE: Config file "C:\\Users\\kalem\\AppData\\Roaming\\rclone\\rclone.conf" not found - using defaults
    2021/11/25 22:30:23 NOTICE: Local file system at //?/F:/: WebDav Server started on http://localhost:8080/
    
    kalem@DESKTOP-R6MR0O4 MINGW64 /f/Downloads/rclone-v1.57.0-windows-amd64
    > /rclone.exe mount :webdav: x: --streaming-upload-cutoff=0 -v --webdav-url=http://localhost:8080/ --buffer-size=0 &
    [2] 2063
    
    2021/11/25 22:30:50 NOTICE: Config file "C:\\Users\\kalem\\AppData\\Roaming\\rclone\\rclone.conf" not found - using defaults
    2021/11/25 22:30:50 INFO  : webdav root '': poll-interval is not supported by this remote
    2021/11/25 22:30:50 NOTICE: webdav root '': --vfs-cache-mode writes or full is recommended for this remote as it can't stream
    The service rclone has been started.
    
    kalem@DESKTOP-R6MR0O4 MINGW64 /f/Downloads/rclone-v1.57.0-windows-amd64
    > cat /dev/random | dd of=/x/test.txt count=1 bs=1
    1+0 records in
    1+0 records out
    1 byte copied, 0,0042309 s, 0,2 kB/s
    2021/11/25 22:30:58 ERROR : test.txt: Failed to copy: The system cannot find the file specified.
    2021/11/25 22:30:58 ERROR : test.txt: WriteFileHandle.New Rcat failed: The system cannot find the file specified.
    
    2021/11/25 22:30:59 ERROR : test.txt: Failed to copy: Method Not Allowed: 405 Method Not Allowed
    2021/11/25 22:30:59 ERROR : test.txt: WriteFileHandle.New Rcat failed: Method Not Allowed: 405 Method Not Allowed
    2021/11/25 22:30:59 ERROR : test.txt: WriteFileHandle.Flush error: Method Not Allowed: 405 Method Not Allowed
    2021/11/25 22:30:59 ERROR : IO error: Method Not Allowed: 405 Method Not Allowed
    
    kalem@DESKTOP-R6MR0O4 MINGW64 /f/Downloads/rclone-v1.57.0-windows-amd64
    >

    that is all fine if change on writeable destination.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions