]> git.proxmox.com Git - pve-storage.git/commitdiff
diskmanage: add helper for udev workaround
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 25 Oct 2021 13:47:47 +0000 (15:47 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 10 Nov 2021 11:35:25 +0000 (12:35 +0100)
to avoid duplication. Current callers pass along at least one device,
but anticipate future callers that might call with the empty list. Do
nothing in that case, rather than triggering everything.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/API2/Disks.pm
PVE/API2/Disks/Directory.pm
PVE/API2/Disks/LVM.pm
PVE/API2/Disks/LVMThin.pm
PVE/API2/Disks/ZFS.pm
PVE/Diskmanage.pm

index 25c9ded4eb7a273beaf0631cb8af92e40ce36742..b6180572cdbd0cd54f14bba841ac51e16020948d 100644 (file)
@@ -306,12 +306,7 @@ __PACKAGE__->register_method ({
 
        my $worker = sub {
            PVE::Diskmanage::wipe_blockdev($disk);
-
-           # FIXME: Remove once we depend on systemd >= v249.
-           # Work around udev bug https://github.com/systemd/systemd/issues/18525 to ensure the
-           # udev database is updated.
-           eval { run_command(['udevadm', 'trigger', $disk]); };
-           warn $@ if $@;
+           PVE::Diskmanage::udevadm_trigger($disk);
        };
 
        my $basename = basename($disk); # avoid '/' in the ID
index 36cebbc9d2a271da62460c15c530ea361a6e797d..e9b05be7ea67533c0607b78071a15f1de2b612b5 100644 (file)
@@ -275,11 +275,7 @@ __PACKAGE__->register_method ({
 
                $write_ini->($ini, $mountunitpath);
 
-               # FIXME: Remove once we depend on systemd >= v249.
-               # Work around udev bug https://github.com/systemd/systemd/issues/18525 to ensure the
-               # udev database is updated and the $uuid_path symlink is actually created!
-               eval { run_command(['udevadm', 'trigger', $part]); };
-               warn $@ if $@;
+               PVE::Diskmanage::udevadm_trigger($part);
 
                run_command(['systemctl', 'daemon-reload']);
                run_command(['systemctl', 'enable', $mountunitname]);
index ee9e282faf76b971d923731da1978167d35b7eca..1b88af2ff03fbaacc00e50d14f772d7e46950d47 100644 (file)
@@ -163,11 +163,7 @@ __PACKAGE__->register_method ({
 
                PVE::Storage::LVMPlugin::lvm_create_volume_group($dev, $name);
 
-               # FIXME: Remove once we depend on systemd >= v249.
-               # Work around udev bug https://github.com/systemd/systemd/issues/18525 to ensure the
-               # udev database is updated.
-               eval { run_command(['udevadm', 'trigger', $dev]); };
-               warn $@ if $@;
+               PVE::Diskmanage::udevadm_trigger($dev);
 
                if ($param->{add_storage}) {
                    my $storage_params = {
index 52f3062be5c48f7a76a62cc286e66e88c8c1838a..23f262a5dfdbf026a6254a04c34455ef2533527a 100644 (file)
@@ -141,11 +141,7 @@ __PACKAGE__->register_method ({
                    $name
                ]);
 
-               # FIXME: Remove once we depend on systemd >= v249.
-               # Work around udev bug https://github.com/systemd/systemd/issues/18525 to ensure the
-               # udev database is updated.
-               eval { run_command(['udevadm', 'trigger', $dev]); };
-               warn $@ if $@;
+               PVE::Diskmanage::udevadm_trigger($dev);
 
                if ($param->{add_storage}) {
                    my $storage_params = {
index e8d5e7c1c8d83afa27f6ec90b7c749cb94c844cd..e8927123da265b7ea72404bee1608cbd609e4e96 100644 (file)
@@ -426,11 +426,7 @@ __PACKAGE__->register_method ({
                    run_command($cmd);
                }
 
-               # FIXME: Remove once we depend on systemd >= v249.
-               # Work around udev bug https://github.com/systemd/systemd/issues/18525 to ensure the
-               # udev database is updated.
-               eval { run_command(['udevadm', 'trigger', $devs->@*]); };
-               warn $@ if $@;
+               PVE::Diskmanage::udevadm_trigger($devs->@*);
 
                if ($param->{add_storage}) {
                    my $storage_params = {
index 18459f95291a5f70af8c051d49208cb7705fee71..d67cc6b2ab255661afc8c5dd00f66e19a1db5cbc 100644 (file)
@@ -966,4 +966,15 @@ sub wipe_blockdev {
     }
 }
 
+# FIXME: Remove once we depend on systemd >= v249.
+# Work around udev bug https://github.com/systemd/systemd/issues/18525 ensuring database is updated.
+sub udevadm_trigger {
+    my @devs = @_;
+
+    return if scalar(@devs) == 0;
+
+    eval { run_command(['udevadm', 'trigger', @devs]); };
+    warn $@ if $@;
+}
+
 1;