From: Jianpeng Ma Date: Fri, 30 Jan 2015 05:21:44 +0000 (+0800) Subject: osdc: For read w/ DONTNEED, if read data contain all cached data, move this object... X-Git-Tag: v0.93~139^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ed209a5ea24f6b7762aea853b7230f43aec559f2;p=ceph.git 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 --- diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index d42c802b5ad0..2000f6448336 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -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::iterator first = data.begin(); + map::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); } } diff --git a/src/osdc/ObjectCacher.h b/src/osdc/ObjectCacher.h index da7b17d95d79..0c6e71cf9281 100644 --- a/src/osdc/ObjectCacher.h +++ b/src/osdc/ObjectCacher.h @@ -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& hits, map& 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);