mirror of
https://github.com/ceph/ceph
synced 2025-02-19 00:47:49 +00:00
librbd: don't do readahead when m_readahead_pos reaching limit
When m_readahead_pos reaches the limit, there's no need to call _compute_readahead to calculate the readahead. Just return with no readahead. Signed-off-by: Zhiqiang Wang <zhiqiang.wang@intel.com>
This commit is contained in:
parent
04fe26921f
commit
b47a5499a0
@ -30,6 +30,10 @@ 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) {
|
for (vector<extent_t>::const_iterator p = extents.begin(); p != extents.end(); ++p) {
|
||||||
_observe_read(p->first, p->second);
|
_observe_read(p->first, p->second);
|
||||||
}
|
}
|
||||||
|
if (m_readahead_pos >= limit) {
|
||||||
|
m_lock.Unlock();
|
||||||
|
return extent_t(0, 0);
|
||||||
|
}
|
||||||
pair<uint64_t, uint64_t> extent = _compute_readahead(limit);
|
pair<uint64_t, uint64_t> extent = _compute_readahead(limit);
|
||||||
m_lock.Unlock();
|
m_lock.Unlock();
|
||||||
return extent;
|
return extent;
|
||||||
@ -38,6 +42,10 @@ 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) {
|
Readahead::extent_t Readahead::update(uint64_t offset, uint64_t length, uint64_t limit) {
|
||||||
m_lock.Lock();
|
m_lock.Lock();
|
||||||
_observe_read(offset, length);
|
_observe_read(offset, length);
|
||||||
|
if (m_readahead_pos >= limit) {
|
||||||
|
m_lock.Unlock();
|
||||||
|
return extent_t(0, 0);
|
||||||
|
}
|
||||||
extent_t extent = _compute_readahead(limit);
|
extent_t extent = _compute_readahead(limit);
|
||||||
m_lock.Unlock();
|
m_lock.Unlock();
|
||||||
return extent;
|
return extent;
|
||||||
@ -52,6 +60,7 @@ void Readahead::_observe_read(uint64_t offset, uint64_t length) {
|
|||||||
m_consec_read_bytes = 0;
|
m_consec_read_bytes = 0;
|
||||||
m_readahead_trigger_pos = 0;
|
m_readahead_trigger_pos = 0;
|
||||||
m_readahead_size = 0;
|
m_readahead_size = 0;
|
||||||
|
m_readahead_pos = 0;
|
||||||
}
|
}
|
||||||
m_last_pos = offset + length;
|
m_last_pos = offset + length;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user