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;
}
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;
}
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;
}
<< 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;
}
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;
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;
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;
}
return -EINVAL;
}
- int r = ictx_check(ictx, true);
+ int r = ictx_check(ictx, ictx->owner_lock);
if (r < 0) {
return r;
}
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);