Commit 3d6d4aca authored by Mike Hibler's avatar Mike Hibler

Synchronize the activities of the OOB interface with the vnode interface.

Aka, add some locking, stupid!
parent c9faef6e
#!/usr/bin/perl -wT
#
# Copyright (c) 2013-2017 University of Utah and the Flux Group.
# Copyright (c) 2013-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -333,10 +333,10 @@ sub create($$$;$)
return 1;
}
my $rv = freenasVolumeCreate($pool, $vol, $size, $sparse);
my $rv = freenasVolumeCreate($pool, $vol, $size, $sparse, 1);
if ($rv == 0 && $fstype ne "none") {
$rv = freenasFSCreate($pool, $vol, $fstype);
if ($rv && freenasVolumeDestroy($pool, $vol)) {
$rv = freenasFSCreate($pool, $vol, $fstype, 1);
if ($rv && freenasVolumeDestroy($pool, $vol, 1)) {
print STDERR "bscontrol_proxy: could not destroy new volume ".
"after FS creation failure.\n";
}
......@@ -368,7 +368,7 @@ sub snapshot($$$)
return 1;
}
return freenasVolumeSnapshot($pool, $vol, $tstamp);
return freenasVolumeSnapshot($pool, $vol, $tstamp, 1);
}
sub desnapshot($$$)
......@@ -396,7 +396,7 @@ sub desnapshot($$$)
}
}
return freenasVolumeDesnapshot($pool, $vol, $tstamp, 0);
return freenasVolumeDesnapshot($pool, $vol, $tstamp, 0, 1);
}
sub desnapshotall($$)
......@@ -416,7 +416,7 @@ sub desnapshotall($$)
return 1;
}
return freenasVolumeDesnapshot($pool, $vol, undef, 1);
return freenasVolumeDesnapshot($pool, $vol, undef, 1, 1);
}
sub clone($$$;$)
......@@ -453,7 +453,7 @@ sub clone($$$;$)
$tstamp = 0;
}
return freenasVolumeClone($pool, $ovol, $nvol, $tstamp);
return freenasVolumeClone($pool, $ovol, $nvol, $tstamp, 1);
}
sub destroy($$$)
......@@ -473,7 +473,7 @@ sub destroy($$$)
return 1;
}
return freenasVolumeDestroy($pool, $vol);
return freenasVolumeDestroy($pool, $vol, 1);
}
sub declone($$$)
......@@ -493,5 +493,5 @@ sub declone($$$)
return 1;
}
return freenasVolumeDeclone($pool, $vol);
return freenasVolumeDeclone($pool, $vol, 1);
}
This diff is collapsed.
#!/usr/bin/perl -wT
#
# Copyright (c) 2013-2017 University of Utah and the Flux Group.
# Copyright (c) 2013-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -651,7 +651,7 @@ sub allocSlice($$$$) {
$priv->{'pool'} = $bsid;
$priv->{'volume'} = $vnode_id;
return freenasVolumeCreate($bsid, $vnode_id, $size, $sparse);
return freenasVolumeCreate($bsid, $vnode_id, $size, $sparse, 0);
}
# Setup device export.
......@@ -736,16 +736,17 @@ sub exportSlice($$$$) {
# we assume another mapping has already gone through here and
# we just use the same snapshot.
#
# XXX could this race with another vnode setup? If so, we could
# wind up creating multiple snapshots for the same volume.
# That does not matter right now, but something to watch out for.
# N.B. the global lock serializes vnode_creates here so we do
# not have to worry about racing and creating multiple snapshots.
# However, the OOB path through bscontrol.proxy needs to respect
# the lock as well or we *will* wind up with multiple snapshots.
#
if (!exists($priv->{'lastsnapshot'})) {
# XXX this will be an error
warn("*** WARNING: blockstore_exportSlice: $volname: ".
"no snapshot found; created one for now");
my $tstamp = time();
if (freenasVolumeSnapshot($pool, $volume, $tstamp)) {
if (freenasVolumeSnapshot($pool, $volume, $tstamp, 0)) {
warn("*** ERROR: blockstore_exportSlice: $volname: ".
"Could not create snapshot for RO/Clone mapping");
return -1;
......@@ -760,7 +761,7 @@ sub exportSlice($$$$) {
# Clone will use the most recent snapshot (though there should
# only be one anyway).
#
if (freenasVolumeClone($pool, $volume, $vnode_id)) {
if (freenasVolumeClone($pool, $volume, $vnode_id, 0, 0)) {
warn("*** ERROR: blockstore_exportSlice: $volname: ".
"Could not create clone for RO/Clone mapping");
return -1;
......@@ -1403,9 +1404,9 @@ sub deallocSlice($$$$) {
# which could be a long time ago (and hence very stale).
#
if (defined($snaps) && $cloneof eq (split(',', $snaps))[0]) {
return freenasVolumeDestroy($pool, $vnode_id);
return freenasVolumeDestroy($pool, $vnode_id, 0);
}
return freenasVolumeDeclone($pool, $vnode_id);
return freenasVolumeDeclone($pool, $vnode_id, 0);
}
warn("*** WARNING: blockstore_deallocSlice: $volname: ".
"Found stale clone volume '$pool/$vnode_id'");
......@@ -1425,7 +1426,7 @@ sub deallocSlice($$$$) {
# to worry about keeping the latest snapshot as there will only be one
# and it should go away on last use.
#
return freenasVolumeDeclone($bsid, $vnode_id);
return freenasVolumeDeclone($bsid, $vnode_id, 0);
}
# Required perl foo
......
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