From: John Spray Date: Tue, 5 Jan 2016 13:56:21 +0000 (+0000) Subject: client: EPERM instead of ETIMEDOUT on REJECT X-Git-Tag: v10.0.3~48^2~4^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=46030b2ef25a3abea7e5d2a1ee21e4751cb1c50c;p=ceph.git client: EPERM instead of ETIMEDOUT on REJECT ...by allowing MetaRequest to carry a specific error from abort() rather than just a boolean flag. Signed-off-by: John Spray --- diff --git a/src/client/Client.cc b/src/client/Client.cc index f5127ebdaecb..7b41772d1ea5 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -1570,7 +1570,7 @@ int Client::make_request(MetaRequest *request, request->resend_mds = use_mds; while (1) { - if (request->aborted) + if (request->aborted()) break; // set up wait cond @@ -1607,7 +1607,7 @@ int Client::make_request(MetaRequest *request, wait_on_context_list(session->waiting_for_open); // Abort requests on REJECT from MDS if (rejected_by_mds.count(mds)) { - request->aborted = true; + request->abort(-EPERM); break; } continue; @@ -1637,12 +1637,12 @@ int Client::make_request(MetaRequest *request, } if (!request->reply) { - assert(request->aborted); + assert(request->aborted()); assert(!request->got_unsafe); request->item.remove_myself(); unregister_request(request); put_request(request); // ours - return -ETIMEDOUT; + return request->get_abort_code(); } // got it! @@ -5301,7 +5301,7 @@ void Client::tick() if (!mounted && !mds_requests.empty()) { MetaRequest *req = mds_requests.begin()->second; if (req->op_stamp + cct->_conf->client_mount_timeout < now) { - req->aborted = true; + req->abort(-ETIMEDOUT); if (req->caller_cond) { req->kick = true; req->caller_cond->Signal(); diff --git a/src/client/MetaRequest.cc b/src/client/MetaRequest.cc index 330edde1c851..1004f50a77ff 100644 --- a/src/client/MetaRequest.cc +++ b/src/client/MetaRequest.cc @@ -53,6 +53,8 @@ void MetaRequest::dump(Formatter *f) const f->dump_unsigned("num_retry", head.num_retry); f->dump_unsigned("num_fwd", head.num_fwd); f->dump_unsigned("num_releases", head.num_releases); + + f->dump_int("abort_rc", abort_rc); } MetaRequest::~MetaRequest() diff --git a/src/client/MetaRequest.h b/src/client/MetaRequest.h index 660a88a9ac96..bcd96698ec27 100644 --- a/src/client/MetaRequest.h +++ b/src/client/MetaRequest.h @@ -25,6 +25,7 @@ private: InodeRef _inode, _old_inode, _other_inode; Dentry *_dentry; //associated with path Dentry *_old_dentry; //associated with path2 + int abort_rc; public: uint64_t tid; utime_t op_stamp; @@ -52,7 +53,6 @@ public: MClientReply *reply; // the reply bool kick; - bool aborted; bool success; // readdir result @@ -81,7 +81,7 @@ public: InodeRef target; MetaRequest(int op) : - _dentry(NULL), _old_dentry(NULL), + _dentry(NULL), _old_dentry(NULL), abort_rc(0), tid(0), inode_drop(0), inode_unless(0), old_inode_drop(0), old_inode_unless(0), @@ -92,7 +92,7 @@ public: mds(-1), resend_mds(-1), send_to_auth(false), sent_on_mseq(0), num_fwd(0), retry_attempt(0), ref(1), reply(0), - kick(false), aborted(false), success(false), + kick(false), success(false), readdir_offset(0), readdir_end(false), readdir_num(0), got_unsafe(false), item(this), unsafe_item(this), unsafe_dir_item(this), lock("MetaRequest lock"), @@ -102,6 +102,33 @@ public: } ~MetaRequest(); + /** + * Prematurely terminate the request, such that callers + * to make_request will receive `rc` as their result. + */ + void abort(int rc) + { + assert(rc != 0); + abort_rc = rc; + } + + /** + * Whether abort() has been called for this request + */ + inline bool aborted() const + { + return abort_rc != 0; + } + + /** + * Given that abort() has been called for this request, what `rc` was + * passed into it? + */ + int get_abort_code() const + { + return abort_rc; + } + void set_inode(Inode *in) { _inode = in; }