Commit 81dce78f authored by Felix Seibert's avatar Felix Seibert
Browse files

only consider OSDs with sufficient capacity for assignment of new folders

parent 8ce46200
...@@ -186,6 +186,7 @@ class DataDistribution(object): ...@@ -186,6 +186,7 @@ class DataDistribution(object):
# find out which folders are not assigned yet # find out which folders are not assigned yet
new_folders = [] new_folders = []
for a_folder in folders: for a_folder in folders:
# TODO adding folders to OSDs might violate their capacity
containing_osd = self.get_containing_osd(a_folder.id) containing_osd = self.get_containing_osd(a_folder.id)
if containing_osd is not None: if containing_osd is not None:
containing_osd.add_folder(a_folder.id, a_folder.size) containing_osd.add_folder(a_folder.id, a_folder.size)
...@@ -199,7 +200,7 @@ class DataDistribution(object): ...@@ -199,7 +200,7 @@ class DataDistribution(object):
# this information must be returned # this information must be returned
osds_for_new_folders = [] osds_for_new_folders = []
# totally random OSD assignment, even ignoring OSD capacities # totally random OSD assignment, ignoring OSD capacities
# (might lead to I/O errors when too many groups are assigned to an OSD) # (might lead to I/O errors when too many groups are assigned to an OSD)
if random_osd_assignment and ignore_osd_capacities and not ignore_folder_sizes: if random_osd_assignment and ignore_osd_capacities and not ignore_folder_sizes:
if debug: if debug:
...@@ -216,10 +217,7 @@ class DataDistribution(object): ...@@ -216,10 +217,7 @@ class DataDistribution(object):
if debug: if debug:
print("using random osd assignment, respecting osd capacities") print("using random osd assignment, respecting osd capacities")
for a_folder in new_folders: for a_folder in new_folders:
suitable_osds = [] # list of OSDs with enough capacity suitable_osds = self.get_suitable_osds(a_folder.size) # list of OSDs with enough capacity
for one_osd in self.OSDs.values():
if one_osd.capacity - one_osd.total_folder_size - a_folder.size >= 0:
suitable_osds.append(one_osd)
suitable_random_osd = random.choice(suitable_osds) suitable_random_osd = random.choice(suitable_osds)
suitable_random_osd.add_folder(a_folder.id, a_folder.size) suitable_random_osd.add_folder(a_folder.id, a_folder.size)
osds_for_new_folders.append((a_folder.id, osds_for_new_folders.append((a_folder.id,
...@@ -426,6 +424,18 @@ class DataDistribution(object): ...@@ -426,6 +424,18 @@ class DataDistribution(object):
return movements return movements
def get_suitable_osds(self, folder_size):
"""
create a list of OSDs with at least folder_size free capacity.
:return:
"""
suitable_osds = []
for one_osd in self.OSDs.values():
if one_osd.capacity - one_osd.total_folder_size - folder_size >= 0:
suitable_osds.append(one_osd)
return suitable_osds
def get_lpt_osd(self, folder_size): def get_lpt_osd(self, folder_size):
""" """
calculate the processing time of all OSDs, using the sum of their current total_folder_size and folder_size. calculate the processing time of all OSDs, using the sum of their current total_folder_size and folder_size.
...@@ -433,7 +443,7 @@ class DataDistribution(object): ...@@ -433,7 +443,7 @@ class DataDistribution(object):
""" """
best_processing_time = None best_processing_time = None
best_processing_time_osd = -1 best_processing_time_osd = -1
for one_osd in self.OSDs.values(): for one_osd in self.get_suitable_osds(folder_size):
processing_time = (one_osd.total_folder_size + folder_size) / one_osd.bandwidth processing_time = (one_osd.total_folder_size + folder_size) / one_osd.bandwidth
if (best_processing_time is None) or processing_time < best_processing_time_osd: if (best_processing_time is None) or processing_time < best_processing_time_osd:
best_processing_time = one_osd best_processing_time = one_osd
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment