From: Yan, Zheng Date: Tue, 27 Oct 2015 06:53:26 +0000 (+0800) Subject: client: fix 'wait unsafe requests' code in _fsync() X-Git-Tag: v10.0.3~120^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a7501c9ac6cdcdcd68d0726a3b5f89402354b0b9;p=ceph.git client: fix 'wait unsafe requests' code in _fsync() 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 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index c5dbb23cf82..a7bc60c5ac2 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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);