]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: fix state transition table for disassociation 22892/head
authorVenky Shankar <vshankar@redhat.com>
Mon, 4 Jun 2018 09:34:58 +0000 (05:34 -0400)
committerNathan Cutler <ncutler@suse.com>
Thu, 5 Jul 2018 20:35:31 +0000 (22:35 +0200)
The final state transition when disassociating (removing) images
does not purge the image state map for a given image. This can
also result in uneven balance of images across instances as the
policy implementation relies on this structure to figure out
total number of images tracked.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 895d69f226afd0dfa33909ff9766abf780531787)

src/tools/rbd_mirror/image_map/Policy.cc
src/tools/rbd_mirror/image_map/StateTransition.cc

index 6718b10b774875216b1f2830b45f5077a4ff11d2..30899c5beaa52499b7a28474d44de2c450bd2055 100644 (file)
@@ -258,11 +258,13 @@ bool Policy::finish_action(const std::string &global_image_id, int r) {
     assert(start_action);
   }
 
+  // image state may get purged in execute_policy_action()
+  bool pending_action = image_state.transition.action_type != ACTION_TYPE_NONE;
   if (finish_policy_action) {
     execute_policy_action(global_image_id, &image_state, *finish_policy_action);
   }
 
-  return (image_state.transition.action_type != ACTION_TYPE_NONE);
+  return pending_action;
 }
 
 void Policy::execute_policy_action(
index 1a3f521fe5c7471eccae0e23bb33a0ad87b020d3..76c66f9fa5a7fba30ed2ab23033c6aa840856468 100644 (file)
@@ -65,13 +65,12 @@ const StateTransition::TransitionTable StateTransition::s_transition_table {
   {{STATE_ASSOCIATING,  ACTION_TYPE_ACQUIRE},    {ACTION_TYPE_NONE, {}, {},
                                                   {STATE_ASSOCIATED}}},
 
-  {{STATE_DISSOCIATING, ACTION_TYPE_NONE},       {ACTION_TYPE_RELEASE, {}, {},
-                                                  {}}},
+  {{STATE_DISSOCIATING, ACTION_TYPE_NONE},       {ACTION_TYPE_RELEASE, {},
+                                                 {POLICY_ACTION_UNMAP}, {}}},
   {{STATE_DISSOCIATING, ACTION_TYPE_RELEASE},    {ACTION_TYPE_MAP_REMOVE, {},
-                                                  {POLICY_ACTION_UNMAP}, {}}},
+                                                  {POLICY_ACTION_REMOVE}, {}}},
   {{STATE_DISSOCIATING, ACTION_TYPE_MAP_REMOVE}, {ACTION_TYPE_NONE, {},
-                                                  {POLICY_ACTION_REMOVE},
-                                                  {STATE_UNASSOCIATED}}},
+                                                  {}, {STATE_UNASSOCIATED}}},
 
   {{STATE_SHUFFLING,    ACTION_TYPE_NONE},       {ACTION_TYPE_RELEASE, {},
                                                   {POLICY_ACTION_UNMAP}, {}}},