Clone needs to actually re-read the header to make sure the image is
still protected before returning. Additionally, it needs to consider
the image protected *only* if the protection status is protected -
unprotecting does not count. I thought I'd already fixed this, but
can't find the commit.
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
map<string, SnapInfo>::const_iterator it = snaps_by_name.find(in_snap_name);
if (it != snaps_by_name.end()) {
*is_protected =
- (it->second.protection_status != RBD_PROTECTION_STATUS_UNPROTECTED);
+ (it->second.protection_status == RBD_PROTECTION_STATUS_PROTECTED);
return 0;
}
return -ENOENT;
goto err_close_child;
}
- p_imctx->snap_lock.Lock();
- r = p_imctx->is_snap_protected(p_imctx->snap_name, &snap_protected);
- p_imctx->snap_lock.Unlock();
+ p_imctx->md_lock.Lock();
+ r = ictx_refresh(p_imctx);
+ p_imctx->md_lock.Unlock();
+ if (r == 0) {
+ p_imctx->snap_lock.Lock();
+ r = p_imctx->is_snap_protected(p_imctx->snap_name, &snap_protected);
+ p_imctx->snap_lock.Unlock();
+ }
if (r < 0 || !snap_protected) {
// we lost the race with unprotect
r = -EINVAL;