From fb299d3819f6469c3eecd73efe8cc32ad868628e Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Fri, 10 May 2013 15:45:57 -0700 Subject: [PATCH] librbd: move completion release into rbd_ctx_cb() All the users of rbd_ctx_cb() do this separately right now, but there's no reason to keep the completion around after the nested completion has been called. Also declare rbd_ctx_cb() in the header so it can be used before its definition. Signed-off-by: Josh Durgin --- src/librbd/internal.cc | 5 +---- src/librbd/internal.h | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 80e07ed102faf..21711ae19fc26 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -2243,6 +2243,7 @@ reprotect_and_return_err: Context *ctx = reinterpret_cast(arg); AioCompletion *comp = reinterpret_cast(cb); ctx->complete(comp->get_return_value()); + comp->release(); } int64_t read_iterate(ImageCtx *ictx, uint64_t off, uint64_t len, @@ -2293,7 +2294,6 @@ reprotect_and_return_err: cond.Wait(mylock); mylock.Unlock(); - c->release(); if (ret < 0) return ret; @@ -2529,7 +2529,6 @@ reprotect_and_return_err: cond.Wait(mylock); mylock.Unlock(); - c->release(); return ret; } @@ -2564,7 +2563,6 @@ reprotect_and_return_err: cond.Wait(mylock); mylock.Unlock(); - c->release(); if (ret < 0) return ret; @@ -2601,7 +2599,6 @@ reprotect_and_return_err: cond.Wait(mylock); mylock.Unlock(); - c->release(); if (ret < 0) return ret; diff --git a/src/librbd/internal.h b/src/librbd/internal.h index 4b46594cc913a..a7d39b3c964b6 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -206,6 +206,7 @@ namespace librbd { void rados_req_cb(rados_completion_t cb, void *arg); void rados_ctx_cb(rados_completion_t cb, void *arg); void rbd_req_cb(completion_t cb, void *arg); + void rbd_ctx_cb(completion_t cb, void *arg); } #endif -- 2.39.5