mirror of
https://github.com/ceph/ceph
synced 2024-12-19 01:46:00 +00:00
osdc: For read w/ DONTNEED, if read data contain all cached data, move this object into the tail of LRU.
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
This commit is contained in:
parent
3dca5ef508
commit
ed209a5ea2
@ -176,6 +176,22 @@ bool ObjectCacher::Object::is_cached(loff_t cur, loff_t left)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* all cached data in this range[off, off+len]
|
||||
*/
|
||||
bool ObjectCacher::Object::include_all_cached_data(loff_t off, loff_t len)
|
||||
{
|
||||
assert(oc->lock.is_locked());
|
||||
if (data.empty())
|
||||
return true;
|
||||
map<loff_t, BufferHead*>::iterator first = data.begin();
|
||||
map<loff_t, BufferHead*>::reverse_iterator last = data.rbegin();
|
||||
if (first->second->start() >= off && last->second->end() <= (off + len))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* map a range of bytes into buffer_heads.
|
||||
* - create missing buffer_heads as necessary.
|
||||
@ -1096,6 +1112,8 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
|
||||
if (allzero) {
|
||||
ldout(cct, 10) << "readx ob has all zero|rx, returning ENOENT" << dendl;
|
||||
delete rd;
|
||||
if (dontneed)
|
||||
bottouch_ob(o);
|
||||
return -ENOENT;
|
||||
}
|
||||
}
|
||||
@ -1236,6 +1254,9 @@ int ObjectCacher::_readx(OSDRead *rd, ObjectSet *oset, Context *onfinish,
|
||||
}
|
||||
assert(f_it == ex_it->buffer_extents.end());
|
||||
assert(opos == (loff_t)ex_it->offset + (loff_t)ex_it->length);
|
||||
|
||||
if (dontneed && o->include_all_cached_data(ex_it->offset, ex_it->length))
|
||||
bottouch_ob(o);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -288,6 +288,7 @@ class ObjectCacher {
|
||||
void try_merge_bh(BufferHead *bh);
|
||||
|
||||
bool is_cached(loff_t off, loff_t len);
|
||||
bool include_all_cached_data(loff_t off, loff_t len);
|
||||
int map_read(OSDRead *rd,
|
||||
map<loff_t, BufferHead*>& hits,
|
||||
map<loff_t, BufferHead*>& missing,
|
||||
@ -421,6 +422,9 @@ class ObjectCacher {
|
||||
void touch_ob(Object *ob) {
|
||||
ob_lru.lru_touch(ob);
|
||||
}
|
||||
void bottouch_ob(Object *ob) {
|
||||
ob_lru.lru_bottouch(ob);
|
||||
}
|
||||
|
||||
// bh states
|
||||
void bh_set_state(BufferHead *bh, int s);
|
||||
|
Loading…
Reference in New Issue
Block a user