]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cls/rbd: sanitize entity instance messenger version type
authorJason Dillaman <dillaman@redhat.com>
Tue, 17 Sep 2019 19:49:48 +0000 (15:49 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 18 Sep 2019 14:03:13 +0000 (10:03 -0400)
The entity_addr_t::type field does not uniquely identify the connection
and might switch back and forth between LEGACY, V2, and ALL depending on
the client, the OSD, and the OSD map feature bits. Therefore, always
fix the entity address type to ANY prior to any comparisons.

Fixes: https://tracker.ceph.com/issues/41833
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/cls/rbd/cls_rbd.cc

index 1ab5c8cc00baa463dad2e0cb52dcf7c1b90f3266..fba8d5c0639829ac3e6a76c8fc5543d065dbf761 100644 (file)
@@ -4651,6 +4651,13 @@ int uuid_get(cls_method_context_t hctx, std::string *mirror_uuid) {
   return 0;
 }
 
+void sanitize_entity_inst(entity_inst_t* entity_inst) {
+  // make all addrs of type ANY because the type isn't what uniquely
+  // identifies them and clients and on-disk formats can be encoded
+  // with different backwards compatibility settings.
+  entity_inst->addr.set_type(entity_addr_t::TYPE_ANY);
+}
+
 int list_watchers(cls_method_context_t hctx,
                   std::set<entity_inst_t> *entities) {
   obj_list_watch_response_t watchers;
@@ -4662,7 +4669,10 @@ int list_watchers(cls_method_context_t hctx,
 
   entities->clear();
   for (auto &w : watchers.entries) {
-    entities->emplace(w.name, w.addr);
+    entity_inst_t entity_inst{w.name, w.addr};
+    sanitize_entity_inst(&entity_inst);
+
+    entities->insert(entity_inst);
   }
   return 0;
 }
@@ -4894,6 +4904,7 @@ int image_status_set(cls_method_context_t hctx, const string &global_image_id,
   ondisk_status.last_update = ceph_clock_now();
 
   int r = cls_get_request_origin(hctx, &ondisk_status.origin);
+  sanitize_entity_inst(&ondisk_status.origin);
   ceph_assert(r == 0);
 
   bufferlist bl;