return -ENOENT;
}
+ int ImageCtx::is_snap_unprotected(string in_snap_name,
+ bool *is_unprotected) const
+ {
+ assert(snap_lock.is_locked());
+ map<string, SnapInfo>::const_iterator it = snaps_by_name.find(in_snap_name);
+ if (it != snaps_by_name.end()) {
+ *is_unprotected =
+ (it->second.protection_status == RBD_PROTECTION_STATUS_UNPROTECTED);
+ return 0;
+ }
+ return -ENOENT;
+ }
+
int ImageCtx::get_snap_size(string in_snap_name, uint64_t *out_size) const
{
assert(snap_lock.is_locked());
int get_parent_spec(snapid_t snap_id, parent_spec *pspec);
int get_snap_size(std::string in_snap_name, uint64_t *out_size) const;
int is_snap_protected(string in_snap_name, bool *is_protected) const;
+ int is_snap_unprotected(string in_snap_name, bool *is_unprotected) const;
uint64_t get_current_size() const;
uint64_t get_object_size() const;
if (snap_id == CEPH_NOSNAP)
return -ENOENT;
- bool is_protected;
- r = ictx->is_snap_protected(snap_name, &is_protected);
+ bool is_unprotected;
+ r = ictx->is_snap_unprotected(snap_name, &is_unprotected);
if (r < 0)
return r;
- if (!is_protected)
+ if (is_unprotected)
return -EINVAL;
r = cls_client::set_protection_status(&ictx->md_ctx,
return r;
Mutex::Locker l(ictx->snap_lock);
- return ictx->is_snap_protected(snap_name, is_protected);
+ bool is_unprotected;
+ r = ictx->is_snap_unprotected(snap_name, &is_unprotected);
+ // consider both PROTECTED or UNPROTECTING to be 'protected',
+ // since in either state they can't be deleted
+ *is_protected = !is_unprotected;
+ return r;
}
int create_v1(IoCtx& io_ctx, const char *imgname, uint64_t bid,