]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix 'wait unsafe requests' code in _fsync()
authorYan, Zheng <zyan@redhat.com>
Tue, 27 Oct 2015 06:53:26 +0000 (14:53 +0800)
committerYan, Zheng <zyan@redhat.com>
Thu, 24 Dec 2015 07:49:47 +0000 (15:49 +0800)
Unsafe requests in Inode::unsafe_ops are not sorted in tid order.
So checking first unsafe request's tid does not make sense.

Unsafe requests are requests that are being journalled, they are
arranged in order of journal position. So waiting for the latest
unsafe requests should be enough.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/client/Client.cc

index c5dbb23cf82c1f09c4ee529c7f63956aa94aca61..a7bc60c5ac2e8fb2d03b4cc4f7c3c1c25f6522fd 100644 (file)
@@ -8090,6 +8090,15 @@ int Client::_fsync(Inode *in, bool syncdataonly)
       flushed_metadata = true;
   } else ldout(cct, 10) << "no metadata needs to commit" << dendl;
 
+  if (!syncdataonly && !in->unsafe_ops.empty()) {
+    MetaRequest *req = in->unsafe_ops.back();
+    ldout(cct, 15) << "waiting on unsafe requests, last tid " << req->get_tid() <<  dendl;
+
+    req->get();
+    wait_on_list(req->waitfor_safe);
+    put_request(req);
+  }
+
   if (object_cacher_completion) { // wait on a real reply instead of guessing
     client_lock.Unlock();
     lock.Lock();
@@ -8108,21 +8117,6 @@ int Client::_fsync(Inode *in, bool syncdataonly)
     }
   }
 
-  if (!in->unsafe_ops.empty()) {
-    MetaRequest *req = in->unsafe_ops.back();
-    uint64_t last_tid = req->get_tid();
-    ldout(cct, 15) << "waiting on unsafe requests, last tid " << last_tid <<  dendl;
-
-    do {
-      req->get();
-      wait_on_list(req->waitfor_safe);
-      put_request(req);
-      if (in->unsafe_ops.empty())
-       break;
-      req = in->unsafe_ops.front();
-    } while (req->tid < last_tid);
-  }
-
   if (!r) {
     if (flushed_metadata)
       wait_sync_caps(in, last_flush_tid);