diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/llcache.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/content/llcache.c b/content/llcache.c index 2267f8f8f..9628fd348 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -2427,17 +2427,26 @@ write_backing_store(struct llcache_object *object, * If the overall write bandwidth has fallen below a useful level for * the backing store to be effective disable it. * + * It is important to ensure a useful amount of data has been written + * before calculating bandwidths otherwise tiny files taking a + * disproportionately long time to write might trigger this erroneously. + * * \param p The context pointer passed to the callback. */ static void llcache_persist_slowcheck(void *p) { - unsigned long total_bandwidth; /* total bandwidth */ - total_bandwidth = (llcache->total_written * 1000) / llcache->total_elapsed; + uint64_t total_bandwidth; /* total bandwidth */ + + if (llcache->total_written > (2 * llcache->minimum_bandwidth)) { - if (total_bandwidth < llcache->minimum_bandwidth) { - LOG(("Cannot write minimum bandwidth")); - warn_user("LowDiscWriteBandwidth", 0); - guit->llcache->finalise(); + total_bandwidth = (llcache->total_written * 1000) / llcache->total_elapsed; + + if (total_bandwidth < llcache->minimum_bandwidth) { + LOG(("Current bandwidth %llu less than minimum %llu", + total_bandwidth, llcache->minimum_bandwidth)); + warn_user("LowDiscWriteBandwidth", 0); + guit->llcache->finalise(); + } } } |