Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sketch of an idea to fill several free spaces up reusing existent code #51

Closed
wants to merge 2 commits into from

Conversation

ancorgs
Copy link
Contributor

@ancorgs ancorgs commented Apr 20, 2016

Only PartitionCreator is fully working, the rest is temporary broken (but it's not a big deal)

  • The main idea is to reuse the already working algorithm we have for filling a single FreeDiskSpace (#create_non_lvm_simple)
  • We introduce a previous step (implemented in a separate class) that decides in which free space should we allocate every volume (not sure about the algorithm yet)
  • Then, the original #create_non_lvm_simple is executed for each free space (only with its particular subset of pre-selected volumes)
  • SpaceMaker also uses the new class to decide if the freed space is enough (is not longer just a matter of size)

With this idea, we kinda reduce the problem to write a sensible VolumesDispatcher#distribute method.

That method should solve a problem very similar to the well-known one called "variable sized bin packing problem", a.k.a. VSBPP (info about bin packing in wikipedia). Of course, we don't need a complete solution for it, although it seems to be easily solved using linear programming: paper, one example.

The pull request also includes RSpec tests for several scenarios. The tests pass and proper devicegraphs are generated, probing that all the pieces actually fit together. The bad side if that the tests actually fake VolumesDispatcher#distribute returning always the best distribution for each scenario. We need to write a proper algorithm achieving that without faking... in next sprint.

The current output of those new tests look like this.

Yast::Storage::Proposal::PartitionCreator
  #create_partitions
    when the exact space is available
      creates partitions matching the volume sizes
    when some extra space is available
      distributes the extra space
    when there is no enough space to allocate start of all partitions
      raises an error
    when some volume is marked as 'reuse'
      does not create the reused volumes
      distributes extra space between the new (not reused) volumes
    when a ms-dos type partition is used
      when the only available space is in an extended partition
        creates all partitions as logical
      when the only available space is completely unassigned
        creates primary/extended/logical partitions as needed
    when there are several free spaces
      if all the volumes fit in one space
        creates all the partitions in the same space
        uses the biggest space it can fill completely
      if no single space is big enough
        and all the spaces are inside an extended partition
          creates all partitions as logical
        and the spaces are unassigned (ms-dos partition table)
          creates primary/extended/logical partitions as needed
        if it's possible to avoid gaps
          completely fills all the used spaces
        if it's not possible to fill all the spaces
          creates the smallest possible gap
      if disk restrictions apply to some volume
        if a proper distribution is possible
          honors the disk restrictions
          completely fills all the used spaces
        if the only way to avoid gaps is breaking the disk restrictions
          honors the disk restrictions
          creates the smallest possible gap
        if is not possible to honor the disk restrictions
          raises an error

RSpec tests for SpaceMaker are not included... yet.

@ancorgs
Copy link
Contributor Author

ancorgs commented Apr 21, 2016

Side note: I'm considering to add target_size (:min or :desired) as an attribute to PlannedVolumesList. 90% of the times we pass a list of volumes to a method, we also pass the target size. I'll do if nobody is against.

@ancorgs ancorgs changed the title Sketch of a strategy to fill several free spaces up Sketch of an idea to fill several free spaces up reusing existent code Apr 21, 2016
# @param target_size [Symbol] :desired or :min
#
# @return [Hash{FreeDiskSpace => PlannedVolumesList]
def distribution(volumes, free_spaces, target_size)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'distribute' might be a better name for this; we are using verbs in the imperative form everywhere else. A noun would be more fitting for a class IMHO.

@ancorgs ancorgs force-pushed the multi_space_experiment branch 5 times, most recently from 7a0a8c5 to e60c5c0 Compare April 27, 2016 16:12
 * The main idea is to reuse the already working algorithm we have for filling a
   single FreeDiskSpace (#create_non_lvm_simple)
 * We introduce a previous step (implemented in a separate class) that decides
   in which free space should we allocate every volume (not sure about the
   algorithm yet)
 * Then, the original #create_non_lvm_simple is executed for each free space
   (only with its particular list of pre-selected volumes)
 * SpaceMaker also uses the new class to decide if the freed space is enough
   (is not longer just a matter of size)
@ancorgs ancorgs force-pushed the multi_space_experiment branch 5 times, most recently from 5461d9c to 7de8a0b Compare May 27, 2016 16:07
@ancorgs
Copy link
Contributor Author

ancorgs commented Jun 2, 2016

Closed by #62

@ancorgs ancorgs closed this Jun 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants