]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient: don't use racy check for uncommitted data.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Thu, 2 Jun 2011 18:43:05 +0000 (11:43 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 3 Jun 2011 01:35:45 +0000 (18:35 -0700)
Previously we used a check for if there were CEPH_CAP_FILE_BUFFER refs,
but that was racy if we had other threads (they could hold caps for
sync writes or something). Instead, see if we have any in-flight
writes or uncommitted objects.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/client/Client.cc

index 189989f17fe6ba6e5ce70deb4cb402989c8b0e81..028b51a03f7895880270d610876a8da60a8156c1 100644 (file)
@@ -2189,7 +2189,7 @@ bool Client::_flush(Inode *in, Context *onfinish)
 {
   dout(10) << "_flush " << *in << dendl;
 
-  if (in->cap_refs[CEPH_CAP_FILE_BUFFER] == 0) {
+  if (!in->oset.dirty_tx && in->oset.uncommitted.empty()) {
     dout(10) << " nothing to flush" << dendl;
     return true;
   }
@@ -5054,7 +5054,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf)
 
   if (g_conf.client_oc && (got & CEPH_CAP_FILE_BUFFER)) {
     // do buffered write
-    if (in->cap_refs[CEPH_CAP_FILE_BUFFER] == 0)
+    if (!in->oset.dirty_tx && in->oset.uncommitted.empty())
       get_cap_ref(in, CEPH_CAP_FILE_BUFFER);
 
     get_cap_ref(in, CEPH_CAP_FILE_BUFFER);