From 8fd25776945cd171a7c14bfc94de126bae936f05 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 28 Dec 2018 18:07:09 +0000 Subject: [PATCH] mount,cmount: run Release asynchronously Before this change the mount and cmount would run Release synchronously. This would mean that it would wait for files to be closed (eg uploaded) before returning to the kernel. However Release is already running asynchronously from userspace so this commit changes it to do the functionality of Release asynchronously too. This should fix libfuse blocking when Release is active and it is asked to do something else with a file. Forum: https://forum.rclone.org/t/vfs-cache-mode-writes-upload-expected-behaviour/8014 --- cmd/cmount/fs.go | 6 +++++- cmd/mount/handle.go | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/cmount/fs.go b/cmd/cmount/fs.go index b0a5e511e..335bfb39e 100644 --- a/cmd/cmount/fs.go +++ b/cmd/cmount/fs.go @@ -388,7 +388,11 @@ func (fsys *FS) Release(path string, fh uint64) (errc int) { return errc } _ = fsys.closeHandle(fh) - return translateError(handle.Release()) + // Run the Release asynchronously, ignoring errors + go func() { + _ = handle.Release() + }() + return 0 } // Unlink removes a file. diff --git a/cmd/mount/handle.go b/cmd/mount/handle.go index 2c049abc9..815f15d77 100644 --- a/cmd/mount/handle.go +++ b/cmd/mount/handle.go @@ -80,5 +80,9 @@ var _ fusefs.HandleReleaser = (*FileHandle)(nil) // the kernel func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) (err error) { defer log.Trace(fh, "")("err=%v", &err) - return translateError(fh.Handle.Release()) + // Run the Release asynchronously, ignoring errors + go func() { + _ = fh.Handle.Release() + }() + return nil }