From 2aef095f27e55600f6cbdf6f3d4c4f1fe584f07b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 30 Apr 2015 14:28:18 +0100 Subject: Ensure bandwidth minimum check is only performed when enough data has been written. --- content/llcache.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'content') 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(); + } } } -- cgit v1.2.3