]> xenbits.xensource.com Git - people/aperard/osstest.git/commitdiff
ms-planner: Including Unshare event for previous sharing state
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 21 Nov 2017 15:45:23 +0000 (15:45 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 21 Nov 2017 16:13:46 +0000 (16:13 +0000)
Arrange for the initial plan to contain an Unshare event for resources
which are unallocated, but currently recorded as shared (ie, they
might be ready for reuse).

Specifically, we need to:

 * Include the Wear in the information for a host with no
   unallocatable shares (since the consumers might want to reuse the
   current state).

 * When processing the allocations in cmd_reset, look for sharing
   entries (ie, things we found allocated by magic/shared, and made a
   note in %currentshare) that didn't have any corresponding
   allocations of shares.  Generate an Unshare event for them.

 * When we find an Unshare event in the plan, we used to remove it.
   Now we keep it if it's the first thing in the plan.  (For
   subsequent entries callers don't generally need it because they can
   find the sharing info from previous events.)  When it is the first
   thing in the plan, we do some checks on it.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
ms-planner

index 5d20cc20f5bce222737ae0231cad60c26b521d70..2b8b6c2ea388f94b71b71288dc713540f8931223 100755 (executable)
@@ -151,6 +151,7 @@ END
             OnlyPreparing => 1,
             Shares => $shares->{shares},
             Type => $sharing->{sharetype},
+            Wear => $sharing->{wear},
         };
     }
 
@@ -185,8 +186,21 @@ sub launder_check_plan () {
             };
 
            my $type= $evt->{Type};
-           next if $type eq Unshare;
-
+           if ($type eq Unshare) {
+               if (!@evts) {
+                   # record inherited sharing info
+                   $bad->('unshare not in past')
+                       unless $evt->{Time} <= $plan->{Start};
+                   $bad->('unshare avail')
+                       unless $evt->{Avail} == 1;
+                   my $eshare = $evt->{PreviousShare};
+                   $eshare->{$_} // $bad->("unshare $_")
+                       foreach qw(Type Wear Shares);
+                   push @evts, $evt;
+               }
+               next;
+           }
+               
            push @evts, $evt;
 
             $bad->('type') unless $type eq Start || $type eq End;
@@ -394,6 +408,22 @@ END
        };
     }
 
+    foreach my $reskey (keys %currentshare) {
+       my $cshare = $currentshare{$reskey};
+       next if $plan->{Events}{$reskey};
+       print DEBUG "document existing quiescent sharing $reskey".
+           " share.Type $cshare->{Type}\n";
+       my $evt = {
+            Time => $plan->{Start},
+            Type => Unshare,
+           Avail => 1,
+            Info => 'recently shared $cshare->{Type}',
+            PreviousShare => { %$cshare },
+       };
+       delete $evt->{PreviousShare}{OnlyPreparing};
+       push @{ $plan->{Events}{$reskey} }, $evt;
+    }
+
     # Now everything in the plan is good except that we
     # need to sort the lists and compute Avails, which is done by
     # check_write_new_plan.