]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc: For read w/ DONTNEED, if read data contain all cached data, move this object...
authorJianpeng Ma <jianpeng.ma@intel.com>
Fri, 30 Jan 2015 05:21:44 +0000 (13:21 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Fri, 30 Jan 2015 05:21:44 +0000 (13:21 +0800)
Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index d42c802b5ad068705e6cb9caa9680e48f5d904d3..2000f6448336354ea19638e92dc0a02f9cdf05ff 100644 (file)
@@ -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);
     }
   }
   
index da7b17d95d790bd20082f2ef1870693d2104acac..0c6e71cf92811f810aa5410fb290903b6614f7b6 100644 (file)
@@ -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);