]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: clean up _flush callers
authorSage Weil <sage@newdream.net>
Thu, 19 May 2011 22:01:50 +0000 (15:01 -0700)
committerSage Weil <sage@newdream.net>
Thu, 19 May 2011 22:04:31 +0000 (15:04 -0700)
Have _flush return true if there are no dirty buffers.  Clean up some
redundant conditionals in the callers

Signed-off-by: Sage Weil <sage@newdream.net>
src/client/Client.cc
src/client/Client.h

index 11cd998e1a6d4e277540f7aa417c5d4da2ed8bd7..5fbca40c229628ef3a4adbb89b88f86bc0ed6c25 100644 (file)
@@ -2185,13 +2185,13 @@ void Client::_release(Inode *in, bool checkafter)
 }
 
 
-void Client::_flush(Inode *in, Context *onfinish)
+bool Client::_flush(Inode *in, Context *onfinish)
 {
   dout(10) << "_flush " << *in << dendl;
 
   if (in->cap_refs[CEPH_CAP_FILE_BUFFER] == 0) {
     dout(10) << " nothing to flush" << dendl;
-    return;
+    return true;
   }
 
   if (!onfinish)
@@ -2202,6 +2202,7 @@ void Client::_flush(Inode *in, Context *onfinish)
     onfinish->finish(0);
     delete onfinish;
   }
+  return safe;
 }
 
 void Client::flush_set_callback(ObjectCacher::ObjectSet *oset)
@@ -2936,10 +2937,11 @@ void Client::handle_cap_grant(Inode *in, int mds, InodeCap *cap, MClientCaps *m)
 
     if ((cap->issued & ~old_caps) & CEPH_CAP_FILE_CACHE)
       _release(in, false);
-
-    if ((used & ~new_caps) & CEPH_CAP_FILE_BUFFER)
-      _flush(in);
-    else {
+    
+    if (((used & ~new_caps) & CEPH_CAP_FILE_BUFFER) &&
+       !_flush(in)) {
+      // waitin' for flush
+    } else {
       cap->wanted = 0; // don't let check_caps skip sending a response to MDS
       check_caps(in, true);
     }
@@ -4616,8 +4618,7 @@ int Client::_release(Fh *f)
 
   if (in->snapid == CEPH_NOSNAP) {
     if (in->put_open_ref(f->mode)) {
-      if (in->caps_used() & (CEPH_CAP_FILE_BUFFER|CEPH_CAP_FILE_WR))
-       _flush(in);
+      _flush(in);
       check_caps(in, false);
     }
   } else {
index b36621db989eb77e3d017ccebd739ade0a263682..b73af286571b41aa1bd3373ef5c33cc6e2cc5ddd 100644 (file)
@@ -1104,7 +1104,7 @@ protected:
   void _flushed_cap_snap(Inode *in, snapid_t seq);
 
   void _release(Inode *in, bool checkafter=true);
-  void _flush(Inode *in, Context *onfinish=NULL);
+  bool _flush(Inode *in, Context *onfinish=NULL);
   void _flushed(Inode *in);
   void flush_set_callback(ObjectCacher::ObjectSet *oset);