Skip to content

Commit 1e8d68c

Browse files
Improve Quota Manager accuracy to mitigate "disk full" issues
Depending on the backend used to store data controlled by the Quota Manager (e.g. SQLite), the amount of actual disk space used to store a given amount of data may be much greater than the size of the actual data. Currently, the real disk usage is used only at start to determine the available quota, and after exhausting this quota which ignores the overhead. While the eviction algorithm will attempt to free data across different origins, depending on the origin and total ratios configured, as well as the amount of data written by the app without restarting the browser, we may end up running out of space on constrained devices. To mitigate this, whenever the Quota Manager receives a space request, we force the read of the real usage after consuming 25% of the theoretically available space since the last time the real usage was evaluated. If the remaining available space is too small that the overhead becomes insignificant (100 KB), we just take all remaining space available from that point on.
1 parent f5892cd commit 1e8d68c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Source/WebKit/NetworkProcess/storage/OriginQuotaManager.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ bool OriginQuotaManager::grantWithCurrentQuota(uint64_t spaceRequested)
110110
}
111111
m_quotaCountdown = *m_usage < m_quota ? m_quota - *m_usage : 0;
112112

113+
// As the overhead to store data by the underlying storage backend may be significant, the quota countdown may not
114+
// be accurate enough. Depending on the data size persisted, we may run out of disk space on constraint devices even
115+
// when quota is in theory available (when a lot of data is written without checking the real usage).
116+
// To mitigate this, we force the read of the real usage after consuming 25% of the theoretically available space.
117+
// If the remaining available space is too small that the overhead becomes insignificant (100 KB), we just take all
118+
// remaining space is available from that point on
119+
if (m_quotaCountdown > (100*1024))
120+
m_quotaCountdown /= 4;
121+
113122
return grantFastPath(spaceRequested);
114123
}
115124

0 commit comments

Comments
 (0)