]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: carry inode reference across calls to _flush
authorSage Weil <sage.weil@dreamhost.com>
Wed, 24 Aug 2011 22:04:10 +0000 (15:04 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Wed, 24 Aug 2011 22:04:10 +0000 (15:04 -0700)
Also drop the unused _flush Context* argument.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/client/Client.cc
src/client/Client.h

index 7f7f990a72376a1bf58296acee4fccd69b465517..f4b2e94da2ab899d70d640c4b9791df44fb9d003 100644 (file)
@@ -1728,7 +1728,8 @@ void Client::put_inode(Inode *in, int n)
     remove_all_caps(in);
 
     ldout(cct, 10) << "put_inode deleting " << *in << dendl;
-    objectcacher->release_set(&in->oset);
+    bool unclean = objectcacher->release_set(&in->oset);
+    assert(!unclean);
     if (in->snapdir_parent)
       put_inode(in->snapdir_parent);
     inode_map.erase(in->vino());
@@ -2342,7 +2343,20 @@ void Client::_release(Inode *in, bool checkafter)
 }
 
 
-bool Client::_flush(Inode *in, Context *onfinish)
+class C_Client_PutInode : public Context {
+  Client *client;
+  Inode *in;
+public:
+  C_Client_PutInode(Client *c, Inode *i) : client(c), in(i) {
+    in->get();
+  }
+  void finish(int) {
+    client->put_inode(in);
+  }
+};
+
+
+bool Client::_flush(Inode *in)
 {
   ldout(cct, 10) << "_flush " << *in << dendl;
 
@@ -2351,13 +2365,10 @@ bool Client::_flush(Inode *in, Context *onfinish)
     return true;
   }
 
-  if (!onfinish)
-    onfinish = new C_NoopContext;
-
+  Context *onfinish = new C_Client_PutInode(this, in);
   bool safe = objectcacher->commit_set(&in->oset, onfinish);
-  if (safe && onfinish) {
-    onfinish->finish(0);
-    delete onfinish;
+  if (safe) {
+    onfinish->complete(0);
   }
   return safe;
 }
index bd7479617ffdfa9316d323c6aa468bdae4d9ab09..a29d5af453e7e5ad4dd81f9ceb88faca672feccf 100644 (file)
@@ -311,6 +311,8 @@ protected:
   void put_inode(Inode *in, int n=1);
   void close_dir(Dir *dir);
 
+  friend class C_Client_PutInode; // calls put_inode()
+
   //int get_cache_size() { return lru.lru_get_size(); }
   //void set_cache_size(int m) { lru.lru_set_max(m); }
 
@@ -420,7 +422,7 @@ protected:
   void _invalidate_inode_cache(Inode *in);
   void _invalidate_inode_cache(Inode *in, int64_t off, int64_t len);
   void _release(Inode *in, bool checkafter=true);
-  bool _flush(Inode *in, Context *onfinish=NULL);
+  bool _flush(Inode *in);
   void _flushed(Inode *in);
   void flush_set_callback(ObjectCacher::ObjectSet *oset);