]> git.proxmox.com Git - pve-storage.git/commitdiff
api: disk: work around udev bug to ensure its database is updated
authorFabian Ebner <f.ebner@proxmox.com>
Tue, 28 Sep 2021 11:39:42 +0000 (13:39 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 30 Sep 2021 16:04:25 +0000 (18:04 +0200)
There is a udev bug [0] which can ultimately lead to the udev database
for certain devices not being actively updated. Determining whether a
disk is used or not in get_disks() (in part) relies upon lsblk, which
queries the udev database. Ensure the information is updated by
manually calling 'udevadm trigger' for the changed devices.

It's most important for the 'directory' API path, as mounting depends
on the '/dev/disk/by-uuid'-symlink to be generated.

[0]: https://github.com/systemd/systemd/issues/18525

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

index 6c20931d5d4cecca85c937005c076e50f9779981..96c19fd72964ae48b310809b439aa1c559b8e6b4 100644 (file)
@@ -9,6 +9,7 @@ use HTTP::Status qw(:constants);
 use PVE::Diskmanage;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::SafeSyslog;
+use PVE::Tools qw(run_command);
 
 use PVE::API2::Disks::Directory;
 use PVE::API2::Disks::LVM;
@@ -302,7 +303,15 @@ __PACKAGE__->register_method ({
        my $rpcenv = PVE::RPCEnvironment::get();
        my $authuser = $rpcenv->get_user();
 
-       my $worker = sub { PVE::Diskmanage::wipe_blockdev($disk); };
+       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 $@;
+       };
 
        my $basename = basename($disk); # avoid '/' in the ID
 
index 0068db6bb879fa5cca24efff699339ffbde47c83..12852748d168c614abb3b6fc0d8c23d8d3da9b28 100644 (file)
@@ -266,6 +266,12 @@ __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 $@;
+
                run_command(['systemctl', 'daemon-reload']);
                run_command(['systemctl', 'enable', $mountunitname]);
                run_command(['systemctl', 'start', $mountunitname]);
index 2c216c0f6baeb7d20c3f841a1cd137d944b25c35..eb8f5c0d07856e72b5a1c514674294e04eca9251 100644 (file)
@@ -7,7 +7,7 @@ use PVE::Storage::LVMPlugin;
 use PVE::Diskmanage;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::API2::Storage::Config;
-use PVE::Tools qw(lock_file);
+use PVE::Tools qw(lock_file run_command);
 
 use PVE::RPCEnvironment;
 use PVE::RESTHandler;
@@ -158,6 +158,12 @@ __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 $@;
+
                if ($param->{add_storage}) {
                    my $storage_params = {
                        type => 'lvm',
index 81d91a616034615f35514fd26004e497a0a92676..2fd84845654ffd50c7b74b2df5f9f25b52892b8d 100644 (file)
@@ -132,6 +132,12 @@ __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 $@;
+
                if ($param->{add_storage}) {
                    my $storage_params = {
                        type => 'lvmthin',
index 885b93c151cf755eed76d8f2c2aa15cb421db848..1534631c9a9028fe52698ee60ccf1832409764d3 100644 (file)
@@ -406,6 +406,12 @@ __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 $@;
+
                if ($param->{add_storage}) {
                    my $storage_params = {
                        type => 'zfspool',