From e8f65389d09a477ab064c3ad3cf5878eebb2a226 Mon Sep 17 00:00:00 2001 From: Venky Shankar Date: Tue, 29 May 2018 01:45:40 -0400 Subject: [PATCH] rbd-mirror: schedule rebalancer to level-load instances Policy implementation takes care of evenly balancing images across rbd mirror instances. This is done when images are added to the map and/or instances are added or removed with the exception of image removal -- removing images does not reshuffle other (mapped) images which can result in some of the instances under loaded (in worst case, if one removes images which all map to a particular instance, that instance would remain idle until more images are added or a shuffle is triggered). We could possibly trigger map shuffle when images are removed, but that would change the interface between Policy and ImageMap class (in the form of changes to Policy::remove_images()). Also, policy (and its implementations) would have to do more work when the above class method is invoked. Therefore, an interval based rebalancer is added to ImageMap for periodic rebalancing of images only if the following conditions are met: - policy has been idle for a configured time duration - no scheduled or in-transit operations Signed-off-by: Venky Shankar (cherry picked from commit d96cee13d7427bca617e473c522ad7cf00274566) --- src/common/options.cc | 4 ++ src/tools/rbd_mirror/ImageMap.cc | 65 ++++++++++++++++++++++++++++++++ src/tools/rbd_mirror/ImageMap.h | 6 +++ 3 files changed, 75 insertions(+) diff --git a/src/common/options.cc b/src/common/options.cc index 9b9260b426752..7810a2d964204 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -6471,6 +6471,10 @@ static std::vector