From 244a2ae6a91e2f288cf1ef8c930dec712b588e37 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Sat, 3 Jun 2017 12:33:36 +0800 Subject: [PATCH] client: don't re-send interrupted flock request don't re-send interrupted flock request in cases of mds failover and receiving request forward. Signed-off-by: "Yan, Zheng" (cherry picked from commit 044fabd669fdc8287f5cab0f38a82dfbfe41f0cd) Conflicts: src/client/Client.cc: UserPerms not in jewel --- src/client/Client.cc | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index d66fdc757a4d..611181b49888 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2704,11 +2704,19 @@ void Client::kick_requests(MetaSession *session) for (map::iterator p = mds_requests.begin(); p != mds_requests.end(); ++p) { - if (p->second->got_unsafe) + MetaRequest *req = p->second; + if (req->got_unsafe) + continue; + if (req->aborted()) { + if (req->caller_cond) { + req->kick = true; + req->caller_cond->Signal(); + } continue; - if (p->second->retry_attempt > 0) + } + if (req->retry_attempt > 0) continue; // new requests only - if (p->second->mds == session->mds_num) { + if (req->mds == session->mds_num) { send_request(p->second, session); } } @@ -2729,6 +2737,8 @@ void Client::resend_unsafe_requests(MetaSession *session) MetaRequest *req = p->second; if (req->got_unsafe) continue; + if (req->aborted()) + continue; if (req->retry_attempt == 0) continue; // old requests only if (req->mds == session->mds_num) @@ -9026,11 +9036,13 @@ int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep, if (sleep && switch_interrupt_cb) { // enable interrupt switch_interrupt_cb(callback_handle, req->get()); - ret = make_request(req, -1, -1, NULL, NULL, -1, &bl); - // disable interrupt switch_interrupt_cb(callback_handle, NULL); + if (ret == 0 && req->aborted()) { + // effect of this lock request has been revoked by the 'lock intr' request + ret = req->get_abort_code(); + } put_request(req); } else { ret = make_request(req, -1, -1, NULL, NULL, -1, &bl); @@ -9089,6 +9101,12 @@ int Client::_do_filelock(Inode *in, Fh *fh, int lock_type, int op, int sleep, int Client::_interrupt_filelock(MetaRequest *req) { + // Set abort code, but do not kick. The abort code prevents the request + // from being re-sent. + req->abort(-EINTR); + if (req->mds < 0) + return 0; // haven't sent the request + Inode *in = req->inode(); int lock_type; -- 2.47.3