]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: readahead should not read past end of image
authorJason Dillaman <dillaman@redhat.com>
Wed, 4 May 2016 04:12:05 +0000 (00:12 -0400)
committerJason Dillaman <dillaman@redhat.com>
Tue, 10 May 2016 17:44:04 +0000 (13:44 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit adb14303ccf8a26ed5536bb692ae63d92ac40a9f)

src/common/Readahead.cc

index 55f74db8c06b5bc824c52ed48adbc21646bee75c..34f37dad8144a4df7f5386413424f1d3d168d4e8 100644 (file)
@@ -29,7 +29,7 @@ Readahead::extent_t Readahead::update(const vector<extent_t>& extents, uint64_t
   for (vector<extent_t>::const_iterator p = extents.begin(); p != extents.end(); ++p) {
     _observe_read(p->first, p->second);
   }
-  if (m_readahead_pos >= limit) {
+  if (m_readahead_pos >= limit|| m_last_pos >= limit) {
     m_lock.Unlock();
     return extent_t(0, 0);
   }
@@ -41,7 +41,7 @@ Readahead::extent_t Readahead::update(const vector<extent_t>& extents, uint64_t
 Readahead::extent_t Readahead::update(uint64_t offset, uint64_t length, uint64_t limit) {
   m_lock.Lock();
   _observe_read(offset, length);
-  if (m_readahead_pos >= limit) {
+  if (m_readahead_pos >= limit || m_last_pos >= limit) {
     m_lock.Unlock();
     return extent_t(0, 0);
   }