]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
objectcacher: fix commit callback accounting
authorSage Weil <sage@newdream.net>
Mon, 27 Oct 2008 20:28:43 +0000 (13:28 -0700)
committerSage Weil <sage@newdream.net>
Mon, 27 Oct 2008 20:28:43 +0000 (13:28 -0700)
src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index a807de8f75e94075ae32bc8e72367d77a31e0678..c663b80bae5f4853b1b22f876abef0302f9fe37f 100644 (file)
@@ -501,8 +501,9 @@ void ObjectCacher::bh_write(BufferHead *bh)
   oncommit->tid = tid;
   bh->ob->last_write_tid = tid;
   bh->last_write_tid = tid;
-  if (commit_set_callback)
-    last_write_by_ino[bh->ob->get_ino()] = tid;
+  if (commit_set_callback) {
+    uncommitted_by_ino[bh->ob->get_ino()].push_back(&bh->ob->uncommitted_item);
+  }
 
   mark_tx(bh);
 }
@@ -654,16 +655,19 @@ void ObjectCacher::bh_write_commit(object_t oid, loff_t start, size_t length, ti
   } else {
     Object *ob = objects[oid];
     
-    // is the entire object set now clean and fully committed?
-    if (commit_set_callback && 
-       last_write_by_ino[ob->get_ino()] <= tid) {
-      commit_set_callback(flush_set_callback_arg, ob->get_ino());      
-      last_write_by_ino.erase(ob->get_ino());
-    }
-
     // update last_commit.
     ob->last_commit_tid = tid;
-    
+
+    // is the entire object set now clean and fully committed?
+    if (commit_set_callback &&
+       ob->last_commit_tid == ob->last_write_tid) {
+      ob->uncommitted_item.remove_myself();
+      if (uncommitted_by_ino[ob->get_ino()].empty()) {
+       uncommitted_by_ino.erase(ob->get_ino());
+       commit_set_callback(flush_set_callback_arg, ob->get_ino());      
+      }
+    }
+   
     // waiters?
     if (ob->waitfor_commit.count(tid)) {
       list<Context*> ls;
index e281f68a5fd982f4c801c1fb87671b27143495a1..b4d629adc7a57bc2bd0d55fa64a6237ef2158bac 100644 (file)
@@ -6,6 +6,7 @@
 #include "include/types.h"
 #include "include/lru.h"
 #include "include/Context.h"
+#include "include/xlist.h"
 
 #include "common/Cond.h"
 #include "common/Thread.h"
@@ -115,6 +116,8 @@ class ObjectCacher {
     list<Context*> waitfor_rd;
     list<Context*> waitfor_wr;
 
+    xlist<Object*>::item uncommitted_item;
+
     // lock
     static const int LOCK_NONE = 0;
     static const int LOCK_WRLOCKING = 1;
@@ -134,6 +137,7 @@ class ObjectCacher {
       oc(_oc),
       oid(o), ino(i), layout(l),
       last_write_tid(0), last_ack_tid(0), last_commit_tid(0),
+      uncommitted_item(this),
       lock_state(LOCK_NONE), wrlock_ref(0), rdlock_ref(0)
       {}
     ~Object() {
@@ -212,7 +216,7 @@ class ObjectCacher {
   hash_map<object_t, Object*> objects;
   hash_map<inodeno_t, set<Object*> > objects_by_ino;
   hash_map<inodeno_t, int> dirty_tx_by_ino;
-  hash_map<inodeno_t, tid_t> last_write_by_ino;
+  hash_map<inodeno_t, xlist<Object*> > uncommitted_by_ino;
 
   set<BufferHead*>    dirty_bh;
   LRU   lru_dirty, lru_rest;