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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id EABA4706E1 for ; Tue, 14 Jun 2022 10:53:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D978E1C7F5 for ; Tue, 14 Jun 2022 10:53:22 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id DF0311C7EC for ; Tue, 14 Jun 2022 10:53:21 +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 B4A6441B10 for ; Tue, 14 Jun 2022 10:53:21 +0200 (CEST) Date: Tue, 14 Jun 2022 10:53:14 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20220523105425.3025242-1-a.lauterer@proxmox.com> In-Reply-To: <20220523105425.3025242-1-a.lauterer@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1655196787.f6scuvt4av.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.170 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, rbdplugin.pm] Subject: [pve-devel] applied: [PATCH storage] rbd: get_rbd_dev_path: return /dev/rbd path only if cluster matches 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, 14 Jun 2022 08:53:53 -0000 On May 23, 2022 12:54 pm, Aaron Lauterer wrote: > The changes in cfe46e2d4a97a83f1bbe6ad656e6416399309ba2 git not catch > all situations. > In the case of a guest having 2 disk images with the same name on a pool > with the same name but in two different ceph clusters we still had > issues when starting it. The first disk got mapped as expected. The > second disk did not get mapped because we returned the old $path to > "/dev/rbd//" because it already existed from the first > disk. >=20 > In the case that only the "old" /dev/rbd path exists and we do not have > the /dev/rbd-pve//... path available, we now check if the > cluster fsid used by that rbd device matches the one we expect. If it > does, then we are in the situation that the image has been mapped before > the new rbd-pve udev rule was introduced. If it does not, then we have > the situation of an ambiguous mapping in /dev/rbd and return the > $pve_path. >=20 > Signed-off-by: Aaron Lauterer > --- > PVE/Storage/RBDPlugin.pm | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) >=20 > diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm > index 3511914..eeeaf3f 100644 > --- a/PVE/Storage/RBDPlugin.pm > +++ b/PVE/Storage/RBDPlugin.pm > @@ -3,6 +3,7 @@ package PVE::Storage::RBDPlugin; > use strict; > use warnings; > =20 > +use Cwd qw(abs_path); > use IO::File; > use JSON; > use Net::IP; > @@ -13,7 +14,7 @@ use PVE::JSONSchema qw(get_standard_option); > use PVE::ProcFSTools; > use PVE::RADOS; > use PVE::Storage::Plugin; > -use PVE::Tools qw(run_command trim); > +use PVE::Tools qw(run_command trim file_read_firstline); > =20 > use base qw(PVE::Storage::Plugin); > =20 > @@ -66,7 +67,13 @@ my sub get_rbd_dev_path { > my $pve_path =3D "/dev/rbd-pve/${cluster_id}/${rbd_path}"; > my $path =3D "/dev/rbd/${rbd_path}"; > =20 > - return $path if !-e $pve_path && -e $path; # mapped before rbd-pve u= dev rule existed > + if (!-e $pve_path && -e $path) { > + # possibly mapped before rbd-pve rule existed > + my $real_dev =3D abs_path($path); > + my ($rbd_id) =3D ($real_dev =3D~ m|/dev/rbd([0-9]+)$|); > + my $dev_cluster_id =3D file_read_firstline("/sys/devices/rbd/${rbd_id}/= cluster_fsid"); > + return $path if $cluster_id eq $dev_cluster_id; > + } > return $pve_path; > } > =20 > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20