all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 5/5] plugin: rbd: pass rxbounce when mapping Windows VM guest volumes
Date: Fri, 31 Oct 2025 11:36:12 +0100	[thread overview]
Message-ID: <20251031103709.60233-6-f.weber@proxmox.com> (raw)
In-Reply-To: <20251031103709.60233-1-f.weber@proxmox.com>

When mapping a volume (e.g., because KRBD is enabled) and the hint
'guest-is-windows' is given and true, pass the rxbounce option. This
is to avoid "bad crc/signature" warnings in the journal, retransmits
and degraded performance, see [1]. If the volume is already mapped
without rxbounce (this can be determined from the map options exposed
in sysfs), and it should be mapped with rxbounce, and the
'plugin-may-deactivate-volume' hint denotes it is currently safe to
deactivate the volume, unmap the volume and re-map it with rxbounce.

If 'guest-is-windows' is not given or not true, and the volume is
already mapped, take no action. This also means that guest volumes
that are mapped with rxbounce, but do not have to be (because they do
not belong to a Windows guest), are not deactivated. This can be the
case if a user applied the workaround of adding rxbounce to
'rbd_default_map_options', since this applies to all volumes.

[1] https://bugzilla.proxmox.com/show_bug.cgi?id=5779
[2] https://forum.proxmox.com/threads/155741/post-710845

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
 src/PVE/Storage/RBDPlugin.pm | 42 ++++++++++++++++++++++++++++++++----
 1 file changed, 38 insertions(+), 4 deletions(-)

diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
index 69957d2..7d3e7ab 100644
--- a/src/PVE/Storage/RBDPlugin.pm
+++ b/src/PVE/Storage/RBDPlugin.pm
@@ -90,6 +90,19 @@ my sub get_rbd_dev_path {
     return $pve_path;
 }
 
+my sub read_rbd_map_options {
+    my ($rbd_id) = @_;
+
+    my $sysfs_config_info = file_read_firstline("/sys/devices/rbd/${rbd_id}/config_info");
+    return if !defined($sysfs_config_info);
+
+    my $config_info = [split(/\s+/, $sysfs_config_info)];
+    my $options = @$config_info[1];
+    return if !defined($options);
+
+    return [split(/,/, $options)];
+}
+
 my $rbd_cmd = sub {
     my ($scfg, $storeid, $op, @options) = @_;
 
@@ -799,7 +812,7 @@ sub deactivate_storage {
 }
 
 sub map_volume {
-    my ($class, $storeid, $scfg, $volname, $snapname) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $hints) = @_;
 
     my ($vtype, $img_name, $vmid) = $class->parse_volname($volname);
 
@@ -808,12 +821,33 @@ sub map_volume {
 
     my $kerneldev = get_rbd_dev_path($scfg, $storeid, $name);
 
+    my @extra_options = ();
+
+    if (defined($hints) && $hints->{'guest-is-windows'}) {
+        # make sure to pass rxbounce for Windows guest volumes to avoid degraded performance
+        @extra_options = ('--options', 'rxbounce');
+
+        # if already mapped without rxbounce and deactivation is safe, try to unmap
+        if (-b $kerneldev) {
+            my $mapped_options = read_rbd_map_options(get_rbd_id($kerneldev));
+
+            if ($mapped_options && scalar(grep { /rxbounce/ } @$mapped_options) == 0) {
+                if ($hints->{'plugin-may-deactivate-volume'}) {
+                    eval { $class->unmap_volume($storeid, $scfg, $volname, $snapname); };
+                    warn "could not unmap to apply rxbounce - $@\n" if $@;
+                } else {
+                    warn "not unmapping volume $volname to apply rxbounce since it is not safe\n";
+                }
+            }
+        }
+    }
+
     return $kerneldev if -b $kerneldev; # already mapped
 
     # features can only be enabled/disabled for image, not for snapshot!
     $krbd_feature_update->($scfg, $storeid, $img_name);
 
-    my $cmd = $rbd_cmd->($scfg, $storeid, 'map', $name);
+    my $cmd = $rbd_cmd->($scfg, $storeid, 'map', $name, @extra_options);
     run_rbd_command($cmd, errmsg => "can't map rbd volume $name");
 
     return $kerneldev;
@@ -836,9 +870,9 @@ sub unmap_volume {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache, $hints) = @_;
 
-    $class->map_volume($storeid, $scfg, $volname, $snapname) if $scfg->{krbd};
+    $class->map_volume($storeid, $scfg, $volname, $snapname, $hints) if $scfg->{krbd};
 
     return 1;
 }
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-10-31 10:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 10:36 [pve-devel] [PATCH qemu-server/storage 0/6] fix #5779: introduce guest hints to pass rxbounce flag to KRBD Friedrich Weber
2025-10-31 10:36 ` [pve-devel] [PATCH storage 1/5] plugin: introduce hints for activating and mapping volumes Friedrich Weber
2025-10-31 10:36 ` [pve-devel] [PATCH storage 2/5] plugin api: bump api version and age Friedrich Weber
2025-10-31 10:36 ` [pve-devel] [PATCH storage 3/5] storage: activate/map volumes: verify and pass hints to plugin Friedrich Weber
2025-10-31 10:36 ` [pve-devel] [PATCH storage 4/5] plugin: rbd: factor out subroutine to obtain RBD ID Friedrich Weber
2025-10-31 10:36 ` Friedrich Weber [this message]
2025-10-31 10:36 ` [pve-devel] [PATCH qemu-server 1/1] fix #5779: vm start: pass storage hints when activating guest volumes Friedrich Weber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251031103709.60233-6-f.weber@proxmox.com \
    --to=f.weber@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal