#include "librbd/Utils.h"
#include "librbd/api/Config.h"
#include "librbd/api/Group.h"
+#include "librbd/api/Snapshot.h"
#include "librbd/api/Trash.h"
#include "librbd/deep_copy/MetadataCopyRequest.h"
#include "librbd/deep_copy/SnapshotCopyRequest.h"
}
for (auto &snap : snaps) {
- bool is_protected;
- r = snap_is_protected(m_src_image_ctx, snap.name.c_str(), &is_protected);
+ librbd::snap_namespace_type_t namespace_type;
+ r = Snapshot<I>::get_namespace_type(m_src_image_ctx, snap.id, &namespace_type);
if (r < 0) {
- lderr(m_cct) << "failed retrieving snapshot status: " << cpp_strerror(r)
+ lderr(m_cct) << "error getting snap namespace type: " << cpp_strerror(r)
<< dendl;
return r;
}
- if (is_protected) {
- lderr(m_cct) << "image has protected snapshot '" << snap.name << "'"
+
+ if (namespace_type == RBD_SNAP_NAMESPACE_TYPE_GROUP ||
+ namespace_type == RBD_SNAP_NAMESPACE_TYPE_TRASH) {
+ lderr(m_cct) << "image has group or trash snapshot '" << snap.name << "'"
<< dendl;
return -EBUSY;
+ } else {
+ bool is_protected;
+ r = snap_is_protected(m_src_image_ctx, snap.name.c_str(), &is_protected);
+ if (r < 0) {
+ lderr(m_cct) << "failed retrieving snapshot status: " << cpp_strerror(r)
+ << dendl;
+ return r;
+ }
+ if (is_protected) {
+ lderr(m_cct) << "image has protected snapshot '" << snap.name << "'"
+ << dendl;
+ return -EBUSY;
+ }
}
}