"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: fix very high load caused by slow directory listings
Nick Craig-Wood2adc057d9500
diff --git a/vfs/dir.go b/vfs/dir.goindex 4cba1375e..a6889eb4c 100644--- a/vfs/dir.go+++ b/vfs/dir.go@@ -7,6 +7,7 @@ import ("sort""strings""sync"+ "sync/atomic""time""github.com/pkg/errors"@@ -33,7 +34,7 @@ type Dir struct {read time.Time // time directory entry last readitems map[string]Node // directory entries - can be empty but not nilvirtual map[string]vState // virtual directory entries - may be nil- sys interface{} // user defined info to be attached here+ sys atomic.Value // user defined info to be attached here}//go:generate stringer -type=vState@@ -105,16 +106,12 @@ func (d *Dir) Path() (name string) {// Sys returns underlying data source (can be nil) - satisfies Node interfacefunc (d *Dir) Sys() interface{} {- d.mu.RLock()- defer d.mu.RUnlock()- return d.sys+ return d.sys.Load()}// SetSys sets the underlying data source (can be nil) - satisfies Node interfacefunc (d *Dir) SetSys(x interface{}) {- d.mu.Lock()- d.sys = x- d.mu.Unlock()+ d.sys.Store(x)}// Inode returns the inode number - satisfies Node interfacediff --git a/vfs/file.go b/vfs/file.goindex 891c6c1cc..aadfcb3ee 100644--- a/vfs/file.go+++ b/vfs/file.go@@ -48,7 +48,7 @@ type File struct {pendingModTime time.Time // will be applied once o becomes available, i.e. after file was writtenpendingRenameFun func(ctx context.Context) error // will be run/renamed after all writers closeappendMode bool // file was opened with O_APPEND- sys interface{} // user defined info to be attached here+ sys atomic.Value // user defined info to be attached heremuRW sync.Mutex // synchronize RWFileHandle.openPending(), RWFileHandle.close() and File.Remove}@@ -122,16 +122,12 @@ func (f *File) Path() string {// Sys returns underlying data source (can be nil) - satisfies Node interfacefunc (f *File) Sys() interface{} {- f.mu.RLock()- defer f.mu.RUnlock()- return f.sys+ return f.sys.Load()}// SetSys sets the underlying data source (can be nil) - satisfies Node interfacefunc (f *File) SetSys(x interface{}) {- f.mu.Lock()- f.sys = x- f.mu.Unlock()+ f.sys.Store(x)}// Inode returns the inode number - satisfies Node interface