From: Sage Weil Date: Fri, 17 Oct 2014 03:17:40 +0000 (-0700) Subject: osdc/Objecter: queue an error if reconnect fails X-Git-Tag: v0.91~138 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=909bdbc5a7a2326580f85f2f6b2eb10d810828b9;p=ceph.git osdc/Objecter: queue an error if reconnect fails If we fail to reconnect, trigger the on_error (reusable) context to let the user know about it. Signed-off-by: Sage Weil --- diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index ddcbebc4636..c5e296f7e1d 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -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) diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index a0c89283817..4ffe3f70c1b 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -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); diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index be20ddbb032..d3f39519b9a 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -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,