All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 78fb6465 authored by Mike Hibler's avatar Mike Hibler

Add "desnapshotall" command to the bscontrol path.

When destroying a dataset it is necessary to remove all snapshots,
even those not part of the blockstore subsystem. This adds a path
to allow that.
parent 1d9c4f57
#!/usr/bin/perl -wT
#
# Copyright (c) 2013-2016 University of Utah and the Flux Group.
# Copyright (c) 2013-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -47,6 +47,8 @@ sub usage()
print STDERR " Destroy <vol> in <pool>\n";
print STDERR " desnapshot <pool> <vol> [ <tstamp> ]\n";
print STDERR " Destroy snapshot <vol>/<pool>@<tstamp>; if <tstamp> is not given, destroy all snapshots\n";
print STDERR " desnapshotall <pool> <vol>\n";
print STDERR " Like desnapshot, but removes non-blockstore related snapshots as well\n";
print STDERR " declone <pool> <vol>\n";
print STDERR " Destroy clone <vol> in <pool>; also destroys associated snapshot if this is the last clone\n";
print STDERR "iSCSI-related debugging commands:\n";
......@@ -91,6 +93,7 @@ my %cmds = (
"nextaitag" => \&nexttag,
"targets" => \&targets,
"assocs" => \&assocs,
"desnapshotall" => \&desnapshotall,
);
#
......@@ -389,7 +392,27 @@ sub desnapshot($$$)
}
}
return freenasVolumeDesnapshot($pool, $vol, $tstamp);
return freenasVolumeDesnapshot($pool, $vol, $tstamp, 0);
}
sub desnapshotall($$)
{
my ($pool,$vol) = @_;
if (defined($pool) && $pool =~ /^([-\w]+)$/) {
$pool = $1;
} else {
print STDERR "bscontrol_proxy: bogus pool arg\n";
return 1;
}
if (defined($vol) && $vol =~ /^([-\w]+)$/) {
$vol = $1;
} else {
print STDERR "bscontrol_proxy: bogus volume arg\n";
return 1;
}
return freenasVolumeDesnapshot($pool, $vol, undef, 1);
}
sub clone($$$;$)
......
......@@ -167,7 +167,7 @@ sub freenasRunCmd($$);
sub freenasParseListing($);
sub freenasVolumeSnapshot($$;$);
sub freenasVolumeDesnapshot($$;$);
sub freenasVolumeDesnapshot($$;$$);
sub freenasVolumeClone($$$;$);
sub freenasVolumeDeclone($$);
......@@ -394,7 +394,8 @@ sub freenasVolumeList($;$)
next if (!$vol);
# XXX only track snapshots we create (10 digit timestamp)
next if ($snap->{'name'} !~ /^\d{10}$/);
# XXX note that we do return these if $snapinfo==2
next if ($snap->{'name'} !~ /^\d{10}$/ && $snapinfo != 2);
# XXX only handle zvols right now
next if ($snap->{'parent_type'} ne 'volume');
......@@ -626,9 +627,9 @@ sub freenasVolumeSnapshot($$;$)
return 0;
}
sub freenasVolumeDesnapshot($$;$)
sub freenasVolumeDesnapshot($$;$$)
{
my ($pool, $volname, $tstamp) = @_;
my ($pool, $volname, $tstamp, $force) = @_;
# Untaint arguments that are passed to a command execution
$pool = untaintHostname($pool);
......@@ -645,7 +646,7 @@ sub freenasVolumeDesnapshot($$;$)
}
# Get volume and snapshot info
my $vollist = freenasVolumeList(0, 1);
my $vollist = freenasVolumeList(0, ($force ? 2 : 1));
# The base volume must exist
my $vref = $vollist->{$volname};
......
#!/usr/bin/perl -wT
#
# Copyright (c) 2013-2016 University of Utah and the Flux Group.
# Copyright (c) 2013-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -738,19 +738,17 @@ sub exportSlice($$$$) {
# wind up creating multiple snapshots for the same volume.
# That does not matter right now, but something to watch out for.
#
my $tstamp;
if (!exists($priv->{'lastsnapshot'})) {
# XXX this will be an error
warn("*** WARNING: blockstore_exportSlice: $volname: ".
"no snapshot found; created one for now");
$tstamp = time();
my $tstamp = time();
if (freenasVolumeSnapshot($pool, $volume, $tstamp)) {
warn("*** ERROR: blockstore_exportSlice: $volname: ".
"Could not create snapshot for RO/Clone mapping");
return -1;
}
} else {
$tstamp = $priv->{'lastsnapshot'};
$priv->{'lastsnapshot'} = $tstamp;
}
#
......@@ -763,9 +761,6 @@ sub exportSlice($$$$) {
if (freenasVolumeClone($pool, $volume, $vnode_id)) {
warn("*** ERROR: blockstore_exportSlice: $volname: ".
"Could not create clone for RO/Clone mapping");
if ($tstamp) {
freenasVolumeDesnapshot($pool, $volume, $tstamp);
}
return -1;
}
$volume = $vnode_id;
......
#!/usr/bin/perl -w
#
# Copyright (c) 2013-2016 University of Utah and the Flux Group.
# Copyright (c) 2013-2017 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -999,10 +999,14 @@ sub bs_destroy($$$@)
my $outref;
#
# First destroy any snapshots
# First destroy any snapshots.
#
if (exists($volattrs->{'snapshots'}) &&
bsserver_cmd($srv, "$PROXYCMD desnapshot $pool $name", \$outref)) {
# We do this regardless of whether $volattrs indicates there are
# any snapshots. That state only includes blockstore related snapshots
# and we need to make sure all snapshots are gone, even explicitly
# created ones (e.g., for backup purposes).
#
if (bsserver_cmd($srv, "$PROXYCMD desnapshotall $pool $name", \$outref)) {
print STDERR "*** destroy: ".
"could not destroy snapshots for '$name' on $srv/$pool:";
goto fail;
......
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