From: Jason Dillaman Date: Wed, 8 Jul 2015 00:00:18 +0000 (-0400) Subject: librbd: cleanup ictx_check's handling of owner_lock X-Git-Tag: v10.0.1~52^2~35 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eea016dbb90823eec5c6cea59fcf6d8d15e8736f;p=ceph.git librbd: cleanup ictx_check's handling of owner_lock Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index a94597971e0d..c4e982831a07 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -768,7 +768,7 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type, ldout(ictx->cct, 20) << "snap_create_helper " << ictx << " " << snap_name << dendl; - int r = ictx_check(ictx, true); + int r = ictx_check(ictx, ictx->owner_lock); if (r < 0) { return r; } @@ -842,7 +842,7 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type, ldout(ictx->cct, 20) << __func__ << " " << ictx << " from " << src_snap_id << " to " << dst_name << dendl; - int r = ictx_check(ictx, true); + int r = ictx_check(ictx, ictx->owner_lock); if (r < 0) { return r; } @@ -933,7 +933,7 @@ int invoke_async_request(ImageCtx *ictx, const std::string& request_type, ldout(ictx->cct, 20) << "snap_remove_helper " << ictx << " " << snap_name << dendl; - int r = ictx_check(ictx, true); + int r = ictx_check(ictx, ictx->owner_lock); if (r < 0) { return r; } @@ -2258,7 +2258,7 @@ reprotect_and_return_err: << size << dendl; ictx->snap_lock.put_read(); - int r = ictx_check(ictx, true); + int r = ictx_check(ictx, ictx->owner_lock); if (r < 0) { return r; } @@ -2452,8 +2452,14 @@ reprotect_and_return_err: return 0; } - int ictx_check(ImageCtx *ictx, bool owner_locked) + int ictx_check(ImageCtx *ictx) { + RWLock::RLocker owner_locker(ictx->owner_lock); + return ictx_check(ictx, ictx->owner_lock); + } + + int ictx_check(ImageCtx *ictx, const RWLock &owner_lock) { + assert(ictx->owner_lock.is_locked()); CephContext *cct = ictx->cct; ldout(cct, 20) << "ictx_check " << ictx << dendl; @@ -2462,17 +2468,11 @@ reprotect_and_return_err: ictx->refresh_lock.Unlock(); if (needs_refresh) { - int r; - if (owner_locked) { - r = ictx_refresh(ictx); - } else { - RWLock::RLocker owner_lock(ictx->owner_lock); - r = ictx_refresh(ictx); - } + int r = ictx_refresh(ictx); if (r < 0) { lderr(cct) << "Error re-reading rbd header: " << cpp_strerror(-r) << dendl; - return r; + return r; } } return 0; @@ -3189,7 +3189,7 @@ reprotect_and_return_err: int r; // ictx_check also updates parent data - if ((r = ictx_check(ictx, true)) < 0) { + if ((r = ictx_check(ictx, ictx->owner_lock)) < 0) { lderr(cct) << "ictx_check failed" << dendl; return r; } @@ -3274,7 +3274,7 @@ reprotect_and_return_err: return -EINVAL; } - int r = ictx_check(ictx, true); + int r = ictx_check(ictx, ictx->owner_lock); if (r < 0) { return r; } diff --git a/src/librbd/internal.h b/src/librbd/internal.h index 2dc0aa0ef984..7965c9db8540 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -143,7 +143,8 @@ namespace librbd { int rm_snap(ImageCtx *ictx, const char *snap_name, uint64_t snap_id); int rename_snap(ImageCtx *ictx, uint64_t src_snap_id, const char *dst_name); int refresh_parent(ImageCtx *ictx); - int ictx_check(ImageCtx *ictx, bool owner_locked=false); + int ictx_check(ImageCtx *ictx); + int ictx_check(ImageCtx *ictx, const RWLock &owner_lock); int ictx_refresh(ImageCtx *ictx); int copy(ImageCtx *ictx, IoCtx& dest_md_ctx, const char *destname, ImageOptions& opts, ProgressContext &prog_ctx);