Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

vfs: Add exponential backoff during ENOSPC retries

Leo Luan2295123cad41
diff --git a/vfs/vfscache/cache.go b/vfs/vfscache/cache.go
index 9f6d5ca4e..8faf0e6a7 100644
--- a/vfs/vfscache/cache.go
+++ b/vfs/vfscache/cache.go
@@ -610,7 +610,6 @@ func (c *Cache) clean(removeCleanFiles bool) {
if os.IsNotExist(err) {
return
}
-
c.mu.Lock()
oldItems, oldUsed := len(c.item), fs.SizeSuffix(c.used)
c.mu.Unlock()
diff --git a/vfs/vfscache/item.go b/vfs/vfscache/item.go
index 2ca929b95..22ca1801d 100644
--- a/vfs/vfscache/item.go
+++ b/vfs/vfscache/item.go
@@ -1182,6 +1182,7 @@ func (item *Item) setModTime(modTime time.Time) {
// ReadAt bytes from the file at off
func (item *Item) ReadAt(b []byte, off int64) (n int, err error) {
n = 0
+ var expBackOff int
for retries := 0; retries < fs.Config.LowLevelRetries; retries++ {
item.preAccess()
n, err = item.readAt(b, off)
@@ -1195,6 +1196,12 @@ func (item *Item) ReadAt(b []byte, off int64) (n int, err error) {
break
}
item.c.KickCleaner()
+ expBackOff = 2 << uint(retries)
+ time.Sleep(time.Duration(expBackOff) * time.Millisecond) // Exponential back-off the retries
+ }
+
+ if fserrors.IsErrNoSpace(err) {
+ fs.Errorf(item.name, "vfs cache: failed to _ensure cache after retries %v", err)
}
return n, err