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