Commit a721e561 authored by Mike Hibler's avatar Mike Hibler
Browse files

Mapping changes to support persistent blockstores.

Quite simple actually. In ptopgen we add all persistent stores, which
are identified by having a non-zero lease_idx. To ensure they are only
matched up with the correct virt_blockstore, we add a feature "bs-lease-NN"
where NN is the unique lease index with weight 1.0.

In vtopgen, when a request is made to map a persistent store, we first
verify that the experiment pid matches that of the blockstore's lease
(this is a fer-now simple check which is actually redundant as we make
this check in the parser too) and ensure that the blockstore is not already
mapped (indicated by the blockstore_state entry having size==0) and then
we emit an entry with desire "bs-lease-NN" and weight 1.0.

Most of the file changes were actually to get the "preassign" flag to
vtopgen forwarded into the various libvtop modules so that I can check it
and not perform the permission/size check if it is set.
parent 8ac5ad30
......@@ -28,7 +28,8 @@ use Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK
$VTOP_FLAGS_UPDATE $VTOP_FLAGS_VERBOSE $VTOP_FLAGS_QUIET
$VTOP_FLAGS_FIXNODES $VTOP_FLAGS_IMPOTENT $VTOP_FLAGS_ALLOCONLY
$VTOP_FLAGS_REGRESSION $VTOP_FLAGS_FIXLANNODES);
$VTOP_FLAGS_REGRESSION $VTOP_FLAGS_FIXLANNODES
$VTOP_FLAGS_PREASSIGN);
@ISA = "Exporter";
@EXPORT = qw( );
......@@ -48,10 +49,11 @@ $VTOP_FLAGS_REGRESSION = 0x0;
$VTOP_FLAGS_QUIET = 0x0;
$VTOP_FLAGS_ALLOCONLY = 0x0;
$VTOP_FLAGS_FIXLANNODES = 0x0;
$VTOP_FLAGS_PREASSIGN = 0x0;
@EXPORT_OK = qw($VTOP_FLAGS_UPDATE $VTOP_FLAGS_VERBOSE $VTOP_FLAGS_FIXNODES
$VTOP_FLAGS_IMPOTENT $VTOP_FLAGS_REGRESSION $VTOP_FLAGS_QUIET
$VTOP_FLAGS_ALLOCONLY);
$VTOP_FLAGS_ALLOCONLY $VTOP_FLAGS_PREASSIGN);
sub Init($$$)
{
......@@ -73,6 +75,7 @@ sub Init($$$)
$VTOP_FLAGS_QUIET = $libvtop_test::VTOP_FLAGS_QUIET;
$VTOP_FLAGS_ALLOCONLY = $libvtop_test::VTOP_FLAGS_ALLOCONLY;
$VTOP_FLAGS_FIXLANNODES = $libvtop_test::VTOP_FLAGS_FIXLANNODES;
$VTOP_FLAGS_PREASSIGN = $libvtop_test::VTOP_FLAGS_PREASSIGN;
}
else {
require libvtop_stable;
......@@ -85,6 +88,7 @@ sub Init($$$)
$VTOP_FLAGS_QUIET = $libvtop_stable::VTOP_FLAGS_QUIET;
$VTOP_FLAGS_ALLOCONLY = $libvtop_stable::VTOP_FLAGS_ALLOCONLY;
$VTOP_FLAGS_FIXLANNODES = $libvtop_stable::VTOP_FLAGS_FIXLANNODES;
$VTOP_FLAGS_PREASSIGN = $libvtop_stable::VTOP_FLAGS_PREASSIGN;
}
return 0;
}
......
......@@ -28,7 +28,9 @@ use Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK
$VTOP_FLAGS_UPDATE $VTOP_FLAGS_VERBOSE $VTOP_FLAGS_QUIET
$VTOP_FLAGS_FIXNODES $VTOP_FLAGS_IMPOTENT $VTOP_FLAGS_ALLOCONLY
$VTOP_FLAGS_REGRESSION $VTOP_FLAGS_FIXLANNODES);
$VTOP_FLAGS_REGRESSION $VTOP_FLAGS_FIXLANNODES
$VTOP_FLAGS_PREASSIGN);
@ISA = "Exporter";
@EXPORT = qw( );
......@@ -83,10 +85,12 @@ $VTOP_FLAGS_REGRESSION = 0x10;
$VTOP_FLAGS_QUIET = 0x20;
$VTOP_FLAGS_ALLOCONLY = 0x40;
$VTOP_FLAGS_FIXLANNODES = 0x80;
$VTOP_FLAGS_PREASSIGN = 0x100;
@EXPORT_OK = qw($VTOP_FLAGS_UPDATE $VTOP_FLAGS_VERBOSE $VTOP_FLAGS_FIXNODES
$VTOP_FLAGS_IMPOTENT $VTOP_FLAGS_REGRESSION $VTOP_FLAGS_QUIET
$VTOP_FLAGS_ALLOCONLY $VTOP_FLAGS_FIXLANNODES);
$VTOP_FLAGS_ALLOCONLY $VTOP_FLAGS_FIXLANNODES
$VTOP_FLAGS_PREASSIGN);
#
# Create an object representing the stuff we need to create the vtop file.
......@@ -230,6 +234,7 @@ sub fixlanodes($) { return $_[0]->flags() & $VTOP_FLAGS_FIXLANNODES; }
sub impotent($) { return $_[0]->flags() & $VTOP_FLAGS_IMPOTENT; }
sub alloconly($) { return $_[0]->flags() & $VTOP_FLAGS_ALLOCONLY; }
sub regression($) { return $_[0]->flags() & $VTOP_FLAGS_REGRESSION; }
sub preassign($) { return $_[0]->flags() & $VTOP_FLAGS_PREASSIGN; }
sub printdb($$) { print $_[1] if ($_[0]->verbose()); return 1; }
# We name delay nodes internally as they are needed.
......@@ -1583,6 +1588,20 @@ sub LoadVirtNodes($)
my $attrval = $virt_bs_attr->attrvalue();
my $isdesire = $virt_bs_attr->isdesire();
#
# If this is a persistent blockstore (identified by a lease index
# attribute) then make sure the blockstore is not already mapped.
# If it is currently in use, the remaining capacity will be zero.
# Note: we do not make this check during a pre-assign pass.
#
if ($attrkey eq "lease" && !$self->preassign()) {
my $bs = Blockstore->LookupByLease($attrval);
if ($bs && $bs->AvailableCapacity() == 0) {
tberror("Persistent blockstore $vname is already in use.\n");
return -1;
}
}
# Skip any blockstores that don't have a corresponding entry in the
# 'blockstores' libvtop hash. Also skip any attributes that are not
# marked as a desire.
......
......@@ -28,7 +28,8 @@ use Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK
$VTOP_FLAGS_UPDATE $VTOP_FLAGS_VERBOSE $VTOP_FLAGS_QUIET
$VTOP_FLAGS_FIXNODES $VTOP_FLAGS_IMPOTENT $VTOP_FLAGS_ALLOCONLY
$VTOP_FLAGS_REGRESSION $VTOP_FLAGS_FIXLANNODES);
$VTOP_FLAGS_REGRESSION $VTOP_FLAGS_FIXLANNODES
$VTOP_FLAGS_PREASSIGN);
@ISA = "Exporter";
@EXPORT = qw( );
......@@ -44,6 +45,7 @@ use NodeType;
use Lan;
use OSinfo;
use Blockstore;
use Lease;
use Image;
use Port;
use English;
......@@ -83,10 +85,12 @@ $VTOP_FLAGS_REGRESSION = 0x10;
$VTOP_FLAGS_QUIET = 0x20;
$VTOP_FLAGS_ALLOCONLY = 0x40;
$VTOP_FLAGS_FIXLANNODES = 0x80;
$VTOP_FLAGS_PREASSIGN = 0x100;
@EXPORT_OK = qw($VTOP_FLAGS_UPDATE $VTOP_FLAGS_VERBOSE $VTOP_FLAGS_FIXNODES
$VTOP_FLAGS_IMPOTENT $VTOP_FLAGS_REGRESSION $VTOP_FLAGS_QUIET
$VTOP_FLAGS_ALLOCONLY $VTOP_FLAGS_FIXLANNODES);
$VTOP_FLAGS_ALLOCONLY $VTOP_FLAGS_FIXLANNODES
$VTOP_FLAGS_PREASSIGN);
#
# Create an object representing the stuff we need to create the vtop file.
......@@ -230,6 +234,7 @@ sub fixlanodes($) { return $_[0]->flags() & $VTOP_FLAGS_FIXLANNODES; }
sub impotent($) { return $_[0]->flags() & $VTOP_FLAGS_IMPOTENT; }
sub alloconly($) { return $_[0]->flags() & $VTOP_FLAGS_ALLOCONLY; }
sub regression($) { return $_[0]->flags() & $VTOP_FLAGS_REGRESSION; }
sub preassign($) { return $_[0]->flags() & $VTOP_FLAGS_PREASSIGN; }
sub printdb($$) { print $_[1] if ($_[0]->verbose()); return 1; }
# We name delay nodes internally as they are needed.
......@@ -1608,6 +1613,30 @@ sub LoadVirtNodes($)
my $attrval = $virt_bs_attr->attrvalue();
my $isdesire = $virt_bs_attr->isdesire();
#
# If this is a persistent blockstore (identified by a lease index
# attribute) then make sure the user/pid have access to the lease
# and that the associated blockstore is not already mapped.
# If it is currently in use, the remaining capacity will be zero.
# Note: we do not make this check during a pre-assign pass.
#
if ($attrkey eq "lease" && !$self->preassign()) {
my $lease = Lease->Lookup($attrval);
# XXX need to use the lease_permissions table here
# XXX right now only the project of a lease can access it
if (!$lease || $pid != $lease->pid()) {
warn("Lease $attrval for blockstore $vname does not exist!\n")
if (!$lease);
tberror("Persistent blockstore $vname cannot be used by $pid\n");
return -1;
}
my $bs = Blockstore->LookupByLease($attrval);
if ($bs && $bs->AvailableCapacity() == 0) {
tberror("Persistent blockstore $vname is already in use.\n");
return -1;
}
}
# Skip any blockstores that don't have a corresponding entry in the
# 'blockstores' libvtop hash. Also skip any attributes that are not
# marked as a desire.
......
......@@ -1429,13 +1429,13 @@ foreach $node (@nodenames) {
# Print out all blockstores
#
if ($useblockstore) {
$result = DBQueryFatal("select b.node_id, b.bs_id, b.type, ".
$result = DBQueryFatal("select b.node_id, b.bs_id, b.lease_idx, b.type, ".
"s.remaining_capacity ".
"from blockstores as b ".
"left join blockstore_state as s ".
"on b.bsidx=s.bsidx ".
"where s.ready=1");
while (my ($nodeId, $bsId, $typeName,
while (my ($nodeId, $bsId, $leaseIdx, $typeName,
$capacity) = $result->fetchrow_array) {
my $type = BlockstoreType->Lookup($typeName);
if (defined($type)) {
......@@ -1453,6 +1453,19 @@ if ($useblockstore) {
if (defined($divisible) && $divisible) {
$slots = "*";
}
#
# If this is a persistent block store, i.e. has a non-zero
# lease_idx, we need to ensure that only someone explicitly
# asking for it gets it. We use a unique feature, based on
# the lease index, with a weight of one. This is matched by
# a desire put into the vtop file when someone requests
# mapping of the blockstore.
#
if ($leaseIdx > 0) {
push(@features, "bs-lease-$leaseIdx:1.0");
}
push(@features, "+bs-capacity:$capacity");
print_node("$nodeId:$bsId", ["blockstore:$slots"], \@features,
["subnode_of:$nodeId"], "", $nodetointerface{$nodeId},
......
#!/usr/bin/perl -w
#
# Copyright (c) 2009-2011 University of Utah and the Flux Group.
# Copyright (c) 2009-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -122,6 +122,8 @@ $flags |= $libvtop::VTOP_FLAGS_UPDATE
if ($updating);
$flags |= $libvtop::VTOP_FLAGS_FIXNODES
if ($fixmode);
$flags |= $libvtop::VTOP_FLAGS_PREASSIGN
if ($preassign);
# Open up output file now.
if (defined($filename)) {
......
Markdown is supported
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