]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: EPERM instead of ETIMEDOUT on REJECT
authorJohn Spray <john.spray@redhat.com>
Tue, 5 Jan 2016 13:56:21 +0000 (13:56 +0000)
committerJohn Spray <john.spray@redhat.com>
Tue, 5 Jan 2016 14:07:12 +0000 (14:07 +0000)
...by allowing MetaRequest to carry a specific
error from abort() rather than just a boolean flag.

Signed-off-by: John Spray <john.spray@redhat.com>
src/client/Client.cc
src/client/MetaRequest.cc
src/client/MetaRequest.h

index f5127ebdaecbcaf7b183ad95d99bab1da62e4c1c..7b41772d1ea545fd134b1ae95dd39df75d53db20 100644 (file)
@@ -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();
index 330edde1c851cee40ffc4af73c0ed98b6fa3ad5d..1004f50a77ffa576ad945472c4d75b13e844ae9c 100644 (file)
@@ -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()
index 660a88a9ac966ca630f2d9e3e29e6b06b26533ea..bcd96698ec27e1e6c60d7ab84bda5ab3e9356cb8 100644 (file)
@@ -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;
   }