xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [OSSTEST PATCH 6/6] flight preservation: Provide a way to allocate flights
Date: Tue, 4 Oct 2016 13:26:34 +0100	[thread overview]
Message-ID: <1475583994-30203-6-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1475583994-30203-1-git-send-email-ian.jackson@eu.citrix.com>

Teach mg-allocate to create and delete resources table entries for
flights, as necessary.  And, provide a conveniance alias F/<flight>.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 README.planner | 10 ++++++++--
 mg-allocate    | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/README.planner b/README.planner
index 9d35b40..f3cab53 100644
--- a/README.planner
+++ b/README.planner
@@ -206,9 +206,15 @@ Flight logs and build artefacts are normally expired based on their
 start time, or the start time of the most recent flight which refers
 to them.
 
-Flights can be protected (preserved) by allocating them somehow:
+Flights can be protected (preserved) by allocating them with
+./mg-allocate F/<flight>.
+
 Flights are represented by restype='share-flight' entries in the
-resources table.
+resources table.  Conventionally, the shareix is the owning taskid.
+This allows multiple tasks to lock a single flight.  There is no
+corresponding entry with restype='flight', nor a resource_sharing
+entry.  mg-allocate will create and clean up share-flight entries as
+needed.
 
 
 DETAILED PROTOCOL NOTES
diff --git a/mg-allocate b/mg-allocate
index 0317229..ef57bb8 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -6,6 +6,7 @@
 # <resource-spec> syntax:
 #   [!][<type>/]<name>[/<share>]      type defaults to 'host'
 #                                     type=='S' means 'shared-host'
+#                                     type=='F' means 'shared-flight'
 #                                     share defaults to *
 #                                     "!" prefix means deallocate
 #                                     name=option|option|... means
@@ -112,6 +113,17 @@ sub parse_1res ($) {
     $restype= 'share-host' if $restype eq 'S';
     my $resname= $3;
     my $shareix= $4;
+
+    if ($restype eq 'F') {
+	die unless $resname =~ m/^\d+$/;
+	die unless $resname eq $resname+0;
+	die if defined $shareix;
+	die if $donate_spec;
+	die if @steal_specs;
+	$restype = 'share-flight';
+	$shareix = $tid;
+    }
+
     $shareix= defined($shareix) ? $shareix+0 : '*';
     my $shareixcond = $shareix eq '*' ? '' : "AND shareix = $shareix";
 
@@ -147,6 +159,23 @@ sub alloc_1rescand ($$) {
     my ($res, $rescand) = @_;
     my ($allocate, $restype, $resname, $shareix, $shareixcond) = @$rescand;
 
+    if ($allocate && $restype eq 'share-flight' && $shareix == $tid) {
+	$dbh_tests->do(<<END,{},
+            INSERT INTO resources
+                 (SELECT ? AS restype,
+                         ? AS resname,
+                         ? AS shareix,
+                         ? AS owntaskid
+                   WHERE NOT EXISTS
+                    (SELECT 1 FROM resources
+                         WHERE restype=?
+                           AND resname=?
+                           AND shareix=?))
+END
+		       $restype,$resname,$shareix, $magictask{idle},
+		       $restype,$resname,$shareix);
+    }
+
     my $resq= $dbh_tests->prepare(<<END);
                 SELECT * FROM resources r
                          JOIN tasks t
@@ -257,6 +286,16 @@ END
                 logm("$desc: freeing");
             }
 	    $setres->($donate_taskid // $magictask{idle});
+	    if ($restype eq 'share-flight' && $shareix == $tid) {
+		$dbh_tests->do(<<END,{},
+                    DELETE FROM resources
+                          WHERE restype = ?
+                            AND resname = ?
+                            AND shareix = ?
+                            AND owntaskid = ?
+END
+			       $restype,$resname,$shareix, $magictask{idle});
+	    }
         }
 
         if ($isshared) {
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

      parent reply	other threads:[~2016-10-04 12:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-04 12:26 [OSSTEST PATCH 1/6] cr-ensure-disk-space: Do not take out the lock in dry run mode Ian Jackson
2016-10-04 12:26 ` [OSSTEST PATCH 2/6] cr-ensure-disk-space: -F option Ian Jackson
2016-10-04 12:26 ` [OSSTEST PATCH 3/6] cr-ensure-disk-space: Dry run produces better `die' message Ian Jackson
2016-10-04 12:26 ` [OSSTEST PATCH 4/6] mg-allocate: Tiny refactoring Ian Jackson
2016-10-04 12:26 ` [OSSTEST PATCH 5/6] flight preservation: Honour flight allocation during expiry Ian Jackson
2016-10-04 12:26 ` Ian Jackson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1475583994-30203-6-git-send-email-ian.jackson@eu.citrix.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).