From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 111C36D785 for ; Tue, 28 Sep 2021 13:40:50 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CE6E2DCFA for ; Tue, 28 Sep 2021 13:40:07 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 65645DC9B for ; Tue, 28 Sep 2021 13:40:05 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3B58B44A56 for ; Tue, 28 Sep 2021 13:40:05 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Tue, 28 Sep 2021 13:39:42 +0200 Message-Id: <20210928114001.164081-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210928114001.164081-1-f.ebner@proxmox.com> References: <20210928114001.164081-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.314 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [disks.pm, lvmthin.pm, lvm.pm, directory.pm, zfs.pm] Subject: [pve-devel] [PATCH storage 02/10] api: disk: work around udev bug to ensure its database is updated X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Sep 2021 11:40:50 -0000 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 --- PVE/API2/Disks.pm | 11 ++++++++++- PVE/API2/Disks/Directory.pm | 6 ++++++ PVE/API2/Disks/LVM.pm | 8 +++++++- PVE/API2/Disks/LVMThin.pm | 6 ++++++ PVE/API2/Disks/ZFS.pm | 6 ++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Disks.pm b/PVE/API2/Disks.pm index 6c20931..96c19fd 100644 --- a/PVE/API2/Disks.pm +++ b/PVE/API2/Disks.pm @@ -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 diff --git a/PVE/API2/Disks/Directory.pm b/PVE/API2/Disks/Directory.pm index 0068db6..1285274 100644 --- a/PVE/API2/Disks/Directory.pm +++ b/PVE/API2/Disks/Directory.pm @@ -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]); diff --git a/PVE/API2/Disks/LVM.pm b/PVE/API2/Disks/LVM.pm index 2c216c0..eb8f5c0 100644 --- a/PVE/API2/Disks/LVM.pm +++ b/PVE/API2/Disks/LVM.pm @@ -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', diff --git a/PVE/API2/Disks/LVMThin.pm b/PVE/API2/Disks/LVMThin.pm index 81d91a6..2fd8484 100644 --- a/PVE/API2/Disks/LVMThin.pm +++ b/PVE/API2/Disks/LVMThin.pm @@ -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', diff --git a/PVE/API2/Disks/ZFS.pm b/PVE/API2/Disks/ZFS.pm index 885b93c..1534631 100644 --- a/PVE/API2/Disks/ZFS.pm +++ b/PVE/API2/Disks/ZFS.pm @@ -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', -- 2.30.2