# initialize all plugins
PVE::Storage::Plugin->init();
-my $UDEVADM = '/sbin/udevadm';
-
our $iso_extension_re = qr/\.(?:iso|img)/i;
# PVE::Storage utility functions
return undef;
}
-my $volume_is_base_and_used__no_lock = sub {
- my ($scfg, $storeid, $plugin, $volname) = @_;
+# NOTE: this check does not work for LVM-thin, where the clone -> base
+# reference is not encoded in the volume ID.
+# see note in PVE::Storage::LvmThinPlugin for details.
+sub volume_is_base_and_used {
+ my ($cfg, $volid) = @_;
+
+ my ($storeid, $volname) = parse_volume_id($volid);
+ my $scfg = storage_config($cfg, $storeid);
+ my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
my ($vtype, $name, $vmid, undef, undef, $isBase, undef) =
$plugin->parse_volname($volname);
}
}
return 0;
-};
-
-# NOTE: this check does not work for LVM-thin, where the clone -> base
-# reference is not encoded in the volume ID.
-# see note in PVE::Storage::LvmThinPlugin for details.
-sub volume_is_base_and_used {
- my ($cfg, $volid) = @_;
-
- my ($storeid, $volname) = parse_volume_id($volid);
- my $scfg = storage_config($cfg, $storeid);
- my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
-
- $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
- return &$volume_is_base_and_used__no_lock($scfg, $storeid, $plugin, $volname);
- });
}
# try to map a filesystem path to a volume identifier
or die "receive command failed: $!\n";
close($input);
- my ($ip) = <$info> =~ /^($PVE::Tools::IPRE)$/ or die "no tunnel IP received\n";
- my ($port) = <$info> =~ /^(\d+)$/ or die "no tunnel port received\n";
+ my $try_ip = <$info> // '';
+ my ($ip) = $try_ip =~ /^($PVE::Tools::IPRE)$/ # untaint
+ or die "no tunnel IP received, got '$try_ip'\n";
+
+ my $try_port = <$info> // '';
+ my ($port) = $try_port =~ /^(\d+)$/ # untaint
+ or die "no tunnel port received, got '$try_port'\n";
+
my $socket = IO::Socket::IP->new(PeerHost => $ip, PeerPort => $port, Type => SOCK_STREAM)
or die "failed to connect to tunnel at $ip:$port\n";
# we won't be reading from the socket
$plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
# LVM-thin allows deletion of still referenced base volumes!
die "base volume '$volname' is still in use by linked clones\n"
- if &$volume_is_base_and_used__no_lock($scfg, $storeid, $plugin, $volname);
+ if volume_is_base_and_used($cfg, $volid);
my (undef, undef, undef, undef, undef, $isBase, $format) =
$plugin->parse_volname($volname);
storage_check_enabled($cfg, $storeid) if ($storeid);
- my $res = {};
+ my $res = { map { $_ => [] } keys %{$ids} };
# prepare/activate/refresh all storages
activate_storage_list($cfg, $storage_list, $cache);
- foreach my $sid (keys %$ids) {
+ foreach my $sid (@{$storage_list}) {
next if $storeid && $storeid ne $sid;
- next if !storage_check_enabled($cfg, $sid, undef, 1);
my $scfg = $ids->{$sid};
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
# only call udevsettle if there are events
if ($newseq > $cache->{uevent_seqnum}) {
- my $timeout = 30;
- system ("$UDEVADM settle --timeout=$timeout"); # ignore errors
+ system ("udevadm settle --timeout=30"); # ignore errors
$cache->{uevent_seqnum} = $newseq;
}
foreach my $prune_entry (@{$prune_entries}) {
my $mark = $prune_entry->{mark};
my $id = $id_func->($prune_entry->{ctime});
+ $already_included->{$id} = 1 if defined($mark) && $mark eq 'keep';
+ }
- next if $already_included->{$id};
+ foreach my $prune_entry (@{$prune_entries}) {
+ my $mark = $prune_entry->{mark};
+ my $id = $id_func->($prune_entry->{ctime});
- if (defined($mark)) {
- $already_included->{$id} = 1 if $mark eq 'keep';
- next;
- }
+ next if defined($mark) || $already_included->{$id};
if (!$newly_included->{$id}) {
last if scalar(keys %{$newly_included}) >= $keep_count;
$prune_mark->($prune_list, $keep->{'keep-weekly'}, sub {
my ($ctime) = @_;
my ($sec, $min, $hour, $day, $month, $year) = localtime($ctime);
- my $iso_week = int(strftime("%V", $sec, $min, $hour, $day, $month - 1, $year - 1900));
- my $iso_week_year = int(strftime("%G", $sec, $min, $hour, $day, $month - 1, $year - 1900));
+ my $iso_week = int(strftime("%V", $sec, $min, $hour, $day, $month, $year));
+ my $iso_week_year = int(strftime("%G", $sec, $min, $hour, $day, $month, $year));
return "$iso_week/$iso_week_year";
});
$prune_mark->($prune_list, $keep->{'keep-monthly'}, sub {