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 94E6172824 for ; Tue, 13 Apr 2021 09:53:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8AE2727862 for ; Tue, 13 Apr 2021 09:53:51 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 16E2827858 for ; Tue, 13 Apr 2021 09:53:51 +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 D0395459E7 for ; Tue, 13 Apr 2021 09:53:50 +0200 (CEST) Date: Tue, 13 Apr 2021 09:53:49 +0200 From: Dominic =?iso-8859-1?Q?J=E4ger?= To: Proxmox VE development discussion , Aaron Lauterer Message-ID: <20210413075349.GA18977@mala> References: <20210402101923.13050-1-a.lauterer@proxmox.com> <20210402101923.13050-2-a.lauterer@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210402101923.13050-2-a.lauterer@proxmox.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-SPAM-LEVEL: Spam detection results: 0 AWL 1.586 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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 Subject: Re: [pve-devel] [PATCH v6 storage 1/1] add disk reassign feature 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, 13 Apr 2021 07:53:51 -0000 Needs a rebase since the rbd patches On Fri, Apr 02, 2021 at 12:19:19PM +0200, Aaron Lauterer wrote: > +sub reassign_volume { > + my ($class, $scfg, $storeid, $volname, $target_vmid) = @_; > + > + my $base;; > + (undef, $volname, undef, $base) = $class->parse_volname($volname); > + > + if ($base) { > + $base = $base . '/'; > + } else { > + $base = ''; > + } > + > + $class->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub { > + my $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid); > + return $class->rename_volume($scfg, $storeid, $volname, $target_volname, $target_vmid, $base); > + }); > +} > + > +sub rename_volume { > + my ($class, $scfg, $storeid, $source_volname, $target_volname, $vmid, $base) = @_; > + > + $class->zfs_request($scfg, 5, 'rename', "$scfg->{pool}/$source_volname", "$scfg->{pool}/$target_volname"); > + return "${storeid}:${base}${target_volname}"; > +} 1. imo a ternary would not decrease readability much here and it is only one line > $base = $base ? "$base/" : ""; 2. We could maybe move the if to rename_volume. As far as I see, it is not used in reassign_volume and we could avoid silently guaranteeing properties of $base across subs. And there is a double ;; somewhere