Blob Blame History Raw
From 0b970d4e0cad10a70c920cad0437bf8b278df00d Mon Sep 17 00:00:00 2001
From: Piotr Sarna <sarna@skytechnology.pl>
Date: Mon, 19 Jun 2017 14:38:05 +0200
Subject: [PATCH 3/3] mount: Fix read request size with disabled readahead

This commit makes read requests ask for proper size when readahead
feature is disabled (cacheexpirationtime set to 0).

Change-Id: Ia5d8cfb746d689b1f4750e79721419d02ae7db70
---
 src/mount/readahead_adviser.h | 4 ++++
 src/mount/readdata_cache.h    | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/mount/readahead_adviser.h b/src/mount/readahead_adviser.h
index 1dc89eae..832be05b 100644
--- a/src/mount/readahead_adviser.h
+++ b/src/mount/readahead_adviser.h
@@ -54,6 +54,10 @@ public:
 	 * \param size size of read operation
 	 */
 	void feed(uint64_t offset, uint32_t size) {
+		if (timeout_ms_ == 0) {
+			window_ = 0;
+			return;
+		}
 		addToHistory(size);
 		if (offset == current_offset_) {
 			random_candidates_ = 0;
diff --git a/src/mount/readdata_cache.h b/src/mount/readdata_cache.h
index 37f56e50..717826b6 100644
--- a/src/mount/readdata_cache.h
+++ b/src/mount/readdata_cache.h
@@ -61,7 +61,7 @@ public:
 		}
 
 		bool expired(uint32_t expiration_time) const {
-			return timer.elapsed_ms() > expiration_time;
+			return timer.elapsed_ms() >= expiration_time;
 		}
 
 		Offset endOffset() const {
-- 
2.13.0