]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: ensure groups and images remain in the same namespace
authorJason Dillaman <dillaman@redhat.com>
Thu, 21 Jun 2018 18:25:21 +0000 (14:25 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 22 Jun 2018 14:43:51 +0000 (10:43 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/api/Group.cc

index c2627ba0fb6a621ebe20ea766cd9de32b28ce64f..1d9f6a3434d969ae53ae136ae136b74e1e0b4cb9 100644 (file)
@@ -499,6 +499,11 @@ int Group<I>::image_add(librados::IoCtx& group_ioctx, const char *group_name,
                 << " group name " << group_name << " image "
                 << &image_ioctx << " name " << image_name << dendl;
 
+  if (group_ioctx.get_namespace() != image_ioctx.get_namespace()) {
+    lderr(cct) << "group and image cannot be in different namespaces" << dendl;
+    return -EINVAL;
+  }
+
   string group_id;
 
   int r = cls_client::dir_get_id(&group_ioctx, RBD_GROUP_DIRECTORY, group_name,
@@ -573,6 +578,11 @@ int Group<I>::image_remove(librados::IoCtx& group_ioctx, const char *group_name,
                << " group name " << group_name << " image "
                << &image_ioctx << " name " << image_name << dendl;
 
+  if (group_ioctx.get_namespace() != image_ioctx.get_namespace()) {
+    lderr(cct) << "group and image cannot be in different namespaces" << dendl;
+    return -EINVAL;
+  }
+
   string group_id;
 
   int r = cls_client::dir_get_id(&group_ioctx, RBD_GROUP_DIRECTORY, group_name,