]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Objecter: queue an error if reconnect fails
authorSage Weil <sage@redhat.com>
Fri, 17 Oct 2014 03:17:40 +0000 (20:17 -0700)
committerSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 18:32:38 +0000 (10:32 -0800)
If we fail to reconnect, trigger the on_error (reusable) context to
let the user know about it.

Signed-off-by: Sage Weil <sage@redhat.com>
src/librados/IoCtxImpl.cc
src/osdc/Objecter.cc
src/osdc/Objecter.h

index ddcbebc4636bdde3d5908a38317f96d6058a31a6..c5e296f7e1de6ed9bb3b59e07b92bbedd5d52d9c 100644 (file)
@@ -1056,8 +1056,9 @@ int librados::IoCtxImpl::watch(const object_t& oid,
   bufferlist bl;
   wc->linger_id = objecter->linger_mutate(oid, oloc, wr,
                                          snapc, ceph_clock_now(NULL), bl,
-                                         0,
-                                         NULL, onfinish, &objver);
+                                         *cookie, 0,
+                                         NULL, onfinish, &wc->on_error,
+                                         &objver);
   lock->Unlock();
 
   mylock.Lock();
@@ -1219,6 +1220,7 @@ void librados::IoCtxImpl::set_notify_timeout(uint32_t timeout)
   notify_timeout = timeout;
 }
 
+
 ///////////////////////////// C_aio_Ack ////////////////////////////////
 
 librados::IoCtxImpl::C_aio_Ack::C_aio_Ack(AioCompletionImpl *_c) : c(_c)
index a0c8928381769c10f12d4ad3479ea9968bd1784e..4ffe3f70c1bad5bb27635cd39791f89e78da610f 100644 (file)
@@ -485,6 +485,14 @@ void Objecter::_linger_reconnect(LingerOp *info, int r)
 {
   ldout(cct, 10) << __func__ << " " << info->linger_id << " = " << r
                 << " (last_error " << info->last_error << ")" << dendl;
+  if (r < 0) {
+    info->watch_lock.Lock();
+    info->last_error = r;
+    info->watch_cond.Signal();
+    if (info->on_error)
+      info->on_error->complete(r);
+    info->watch_lock.Unlock();
+  }
 }
 
 void Objecter::unregister_linger(uint64_t linger_id)
@@ -515,11 +523,12 @@ void Objecter::_unregister_linger(uint64_t linger_id)
 }
 
 ceph_tid_t Objecter::linger_mutate(const object_t& oid, const object_locator_t& oloc,
-                             ObjectOperation& op,
-                             const SnapContext& snapc, utime_t mtime,
-                             bufferlist& inbl, int flags,
-                             Context *onack, Context *oncommit,
-                             version_t *objver)
+                                  ObjectOperation& op,
+                                  const SnapContext& snapc, utime_t mtime,
+                                  bufferlist& inbl, uint64_t cookie, int flags,
+                                  Context *onack, Context *oncommit,
+                                  Context *onerror,
+                                  version_t *objver)
 {
   LingerOp *info = new LingerOp;
   info->target.base_oid = oid;
@@ -536,6 +545,7 @@ ceph_tid_t Objecter::linger_mutate(const object_t& oid, const object_locator_t&
   info->pobjver = objver;
   info->on_reg_ack = onack;
   info->on_reg_commit = oncommit;
+  info->on_error = onerror;
 
   RWLock::WLocker wl(rwlock);
   _linger_submit(info);
index be20ddbb03205719847da403a4bfda13dd7877ed..d3f39519b9a774d8e391570898afd958bd9a5f13 100644 (file)
@@ -1460,9 +1460,12 @@ public:
 
     uint64_t cookie;   ///< non-zero if this is a watch
     int last_error;  ///< error from last failed ping|reconnect, if any
+    Mutex watch_lock;
+    Cond watch_cond;
+
     bool registered;
     bool canceled;
-    Context *on_reg_ack, *on_reg_commit;
+    Context *on_reg_ack, *on_reg_commit, *on_error;
 
     OSDSession *session;
 
@@ -1475,9 +1478,11 @@ public:
                 poutbl(NULL), pobjver(NULL),
                 cookie(0),
                 last_error(0),
+                watch_lock("Objecter::LingerOp::watch_lock"),
                 registered(false),
                 canceled(false),
                 on_reg_ack(NULL), on_reg_commit(NULL),
+                on_error(NULL),
                 session(NULL),
                 register_tid(0),
                 map_dne_bound(0) {}
@@ -1937,11 +1942,11 @@ public:
     return op_submit(o, ctx_budget);
   }
   ceph_tid_t linger_mutate(const object_t& oid, const object_locator_t& oloc,
-                     ObjectOperation& op,
-                     const SnapContext& snapc, utime_t mtime,
-                     bufferlist& inbl, int flags,
-                     Context *onack, Context *onfinish,
-                     version_t *objver);
+                          ObjectOperation& op,
+                          const SnapContext& snapc, utime_t mtime,
+                          bufferlist& inbl, uint64_t cookie, int flags,
+                          Context *onack, Context *onfinish, Context *onerror,
+                          version_t *objver);
   ceph_tid_t linger_read(const object_t& oid, const object_locator_t& oloc,
                    ObjectOperation& op,
                    snapid_t snap, bufferlist& inbl, bufferlist *poutbl, int flags,