]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
objectcacher: sort dirty_or_tx_bh in ObjectSet/Object/offset order
authorYan, Zheng <zyan@redhat.com>
Sat, 19 Sep 2015 13:02:13 +0000 (21:02 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 24 Dec 2015 07:49:47 +0000 (15:49 +0800)
so we can find dirty buffer heads in given a ObjectSet easily.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index 745dbe787537a609a0342b0e3a7edc2f82b538c4..e358ed73989afdaeba01215d73975faa2aa5fcff 100644 (file)
@@ -1825,7 +1825,7 @@ bool ObjectCacher::flush_set(ObjectSet *oset, Context *onfinish)
   C_GatherBuilder gather(cct);
   set<Object*> waitfor_commit;
 
-  set<BufferHead*>::iterator next, it;
+  set<BufferHead*, BufferHead::ptr_lt>::iterator next, it;
   next = it = dirty_or_tx_bh.begin();
   while (it != dirty_or_tx_bh.end()) {
     ++next;
index 841ee1fd2e82b90951b7a9dd6fa3d955314bdf73..aa9438b8ebbcf788d512248a638a29231f30ebbf 100644 (file)
@@ -205,6 +205,22 @@ class ObjectCacher {
       return (get_journal_tid() == 0 || bh->get_journal_tid() == 0 ||
              get_journal_tid() == bh->get_journal_tid());
     }
+
+    struct ptr_lt {
+      bool operator()(const BufferHead* l, const BufferHead* r) const {
+       const Object *lob = l->ob;
+       const Object *rob = r->ob;
+       const ObjectSet *loset = lob->oset;
+       const ObjectSet *roset = rob->oset;
+       if (loset != roset)
+         return loset < roset;
+       if (lob != rob)
+         return lob < rob;
+       if (l->start() != r->start())
+         return l->start() < r->start();
+       return l < r;
+      }
+    };
   };
 
   // ******* Object *********
@@ -397,7 +413,7 @@ class ObjectCacher {
 
   ceph_tid_t last_read_tid;
 
-  set<BufferHead*>    dirty_or_tx_bh;
+  set<BufferHead*, BufferHead::ptr_lt> dirty_or_tx_bh;
   LRU   bh_lru_dirty, bh_lru_rest;
   LRU   ob_lru;