]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cls/rbd: sanitize the mirror image status peer address after reading from disk 31824/head
authorJason Dillaman <dillaman@redhat.com>
Fri, 22 Nov 2019 21:39:43 +0000 (16:39 -0500)
committerJason Dillaman <dillaman@redhat.com>
Sat, 23 Nov 2019 14:26:52 +0000 (09:26 -0500)
RADOS upgrade tests were failing when OSDs were partially upgraded since the
entity_addr_t::type overload wasn't being recovered when re-read. Now we will
always sanitize the on-disk entity address after reading it to avoid such
issues of on-disk encoding/decoding.

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

index 9af11cd8539c3ff8fcf550980811f2f9bd19ddc3..4005355e523dd1c3b575503604c79993ba46d760 100644 (file)
@@ -4662,13 +4662,6 @@ 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;
@@ -4681,7 +4674,7 @@ int list_watchers(cls_method_context_t hctx,
   entities->clear();
   for (auto &w : watchers.entries) {
     entity_inst_t entity_inst{w.name, w.addr};
-    sanitize_entity_inst(&entity_inst);
+    cls::rbd::sanitize_entity_inst(&entity_inst);
 
     entities->insert(entity_inst);
   }
@@ -5055,7 +5048,6 @@ 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;
index 32c28dd08b044ef055fe6a7f765bcc113567aa9f..6a8c1c476a500bc6b44305656a44adbe55eddbd5 100644 (file)
@@ -287,7 +287,9 @@ std::ostream& operator<<(std::ostream& os,
 void MirrorImageSiteStatusOnDisk::encode_meta(bufferlist &bl,
                                               uint64_t features) const {
   ENCODE_START(1, 1, bl);
-  encode(origin, bl, features);
+  auto sanitized_origin = origin;
+  sanitize_entity_inst(&sanitized_origin);
+  encode(sanitized_origin, bl, features);
   ENCODE_FINISH(bl);
 }
 
@@ -300,6 +302,7 @@ void MirrorImageSiteStatusOnDisk::encode(bufferlist &bl,
 void MirrorImageSiteStatusOnDisk::decode_meta(bufferlist::const_iterator &it) {
   DECODE_START(1, it);
   decode(origin, it);
+  sanitize_entity_inst(&origin);
   DECODE_FINISH(it);
 }
 
@@ -1146,5 +1149,12 @@ std::ostream& operator<<(std::ostream& os, const AssertSnapcSeqState& state) {
   return os;
 }
 
+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);
+}
+
 } // namespace rbd
 } // namespace cls
index a287f72a4539408977e3484ad5a099134306bd1d..3e5c400de35ed021c3c3eeac2379fa9a78f794f5 100644 (file)
@@ -869,6 +869,8 @@ inline void decode(AssertSnapcSeqState &state, bufferlist::const_iterator& it) {
 
 std::ostream& operator<<(std::ostream& os, const AssertSnapcSeqState& state);
 
+void sanitize_entity_inst(entity_inst_t* entity_inst);
+
 } // namespace rbd
 } // namespace cls