From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 97A0E1FF0AF for ; Fri, 20 Nov 2026 15:10:41 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 89C39217B5; Fri, 20 Nov 2026 15:10:34 +0100 (CET) From: Jonas Theisen To: pve-devel@lists.proxmox.com Subject: [PATCH storage 1/2] rbd: only set image config if the value differs Date: Fri, 20 Nov 2026 15:10:06 +0100 Message-ID: <20261120141020.243160-2-j.theisen@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261120141020.243160-1-j.theisen@proxmox.com> References: <20261120141020.243160-1-j.theisen@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795183830399 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.082 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: FU3ZJNCEPRF7O3FXKKWDZABN7KE5Q6ZT X-Message-ID-Hash: FU3ZJNCEPRF7O3FXKKWDZABN7KE5Q6ZT X-MailFrom: j.theisen@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Starting a VM with an EFI disk on RBD sets the rbd_cache_policy image config on every start, including the target side of a live migration. At that point, the source VM still holds the exclusive lock, so librbd forwards the metadata write to the lock owner, waits for it to report completion, and re-sends the request every 30 seconds until it does. The 'rbd config image set' command can then hang indefinitely if: - the lock owner never reports completion, or - its completion arrives just after a re-send timed out, but before the request is sent again. The requester drops the completion, and the lock owner answers every further re-send of the finished request with its result, 0 on success. That is the same answer as for a request that is still in progress, so the requester keeps waiting for a completion that is never sent again. The VM start on the target, and thus the migration, then hangs until the rbd process is killed. Reading the image config does not involve the lock owner, and after the first start of the VM the value is already set. Check it first and only write it if it differs, so migrations do not need the lock owner anymore in the common case. Signed-off-by: Jonas Theisen --- src/PVE/Storage/RBDPlugin.pm | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm index 26a1cf8..1b2caf8 100644 --- a/src/PVE/Storage/RBDPlugin.pm +++ b/src/PVE/Storage/RBDPlugin.pm @@ -398,9 +398,26 @@ my sub rbd_volume_exists { } # Needs to be public, so qemu-server can mock it for cfg2cmd. +# +# Skips the write if the value is already set. Writing the image config is forwarded to the +# exclusive lock owner, e.g. the source VM during live migration, and can block indefinitely if +# the owner does not complete the request. Reading it does not involve the lock owner. sub rbd_volume_config_set { my ($scfg, $storeid, $volname, $key, $value) = @_; + my $current; + my $get_cmd = $rbd_cmd->($scfg, $storeid, 'config', 'image', 'get', $volname, $key); + # fails if the key is not set yet, so just fall back to setting it on any error + eval { + run_rbd_command( + $get_cmd, + errmsg => "rbd config image get $volname $key error", + errfunc => sub { }, + outfunc => sub { $current = shift }, + ); + }; + return if !$@ && defined($current) && $current eq $value; + my $cmd = $rbd_cmd->($scfg, $storeid, 'config', 'image', 'set', $volname, $key, $value); run_rbd_command($cmd, errmsg => "rbd config image set $volname $key $value error"); @@ -616,9 +633,6 @@ sub qemu_blockdev_options { # SPI flash does lots of read-modify-write OPs, without writeback this gets really slow #3329 if ($options->{hints}->{'efi-disk'}) { - # Querying the value would just cost more and the 'rbd image config get' command will just - # fail if the config has not been set yet, so it's not even straight-forward to do so. - # Simply set the value (possibly again). rbd_volume_config_set($scfg, $storeid, $name, 'rbd_cache_policy', 'writeback'); } -- 2.47.3