From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <d.jaeger@proxmox.com> 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 <pve-devel@lists.proxmox.com>; 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 <pve-devel@lists.proxmox.com>; 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 <pve-devel@lists.proxmox.com>; 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 <pve-devel@lists.proxmox.com>; 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?= <d.jaeger@proxmox.com> To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>, Aaron Lauterer <a.lauterer@proxmox.com> 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 <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=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