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 581E16924F for ; Thu, 12 Nov 2020 17:50:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4DD67132FD for ; Thu, 12 Nov 2020 17:50:28 +0100 (CET) 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 2B529132F1 for ; Thu, 12 Nov 2020 17:50:27 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E806D42272 for ; Thu, 12 Nov 2020 17:50:26 +0100 (CET) To: Proxmox VE development discussion , Dominik Csapak References: <20201112152603.8106-1-d.csapak@proxmox.com> <20201112152603.8106-3-d.csapak@proxmox.com> From: Thomas Lamprecht Message-ID: <41f856f4-1f8b-c518-27f3-cf02f9ed7a20@proxmox.com> Date: Thu, 12 Nov 2020 17:50:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Thunderbird/83.0 MIME-Version: 1.0 In-Reply-To: <20201112152603.8106-3-d.csapak@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL -0.096 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [plugin.pm] Subject: Re: [pve-devel] [PATCH storage 2/2] Storage/Plugin: read .comment files for comments 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: Thu, 12 Nov 2020 16:50:28 -0000 On 12.11.20 16:26, Dominik Csapak wrote: > we have no way of setting them yet via api, but we can read them now >=20 > Signed-off-by: Dominik Csapak > --- > PVE/Storage/Plugin.pm | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) >=20 applied, but dropped the relatively complicated optimizations which avoid= ed a probably cached stat in an edge case - I do not see much value in such over optimizations which make a previous simple sub harder to understand without even noting why it was done anywhere - especially without any sta= ts providing some hard numbers about if and in what environments this actual= ly helps. > diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm > index a046640..00ce9cb 100644 > --- a/PVE/Storage/Plugin.pm > +++ b/PVE/Storage/Plugin.pm > @@ -19,6 +19,8 @@ use base qw(PVE::SectionConfig); > =20 > use constant COMPRESSOR_RE =3D> 'gz|lzo|zst'; > =20 > +use constant COMMENT_EXT =3D> ".comment"; > + > our @COMMON_TAR_FLAGS =3D qw( > --one-file-system > -p --sparse --numeric-owner --acls > @@ -987,8 +989,18 @@ my $get_subdir_files =3D sub { > =20 > my $res =3D []; > =20 > + my $has_comment =3D {}; > + > foreach my $fn (<$path/*>) { > =20 > + if (COMMENT_EXT eq substr($fn, -length(COMMENT_EXT))) { > + my $real_fn =3D substr($fn, 0, length($fn) - length(COMMENT_EXT)= ); > + if (!defined($has_comment->{$real_fn})) { > + $has_comment->{$real_fn} =3D (-f $fn); this is a stat too, so this all only avoided one unused away stat for eac= h unlikely case that a backup has a comment file. > + } > + next; # we do not need to do anything with comments themselves > + } > + > my $st =3D File::stat::stat($fn); > =20 > next if (!$st || S_ISDIR($st->mode)); > @@ -1008,6 +1020,7 @@ my $get_subdir_files =3D sub { > } elsif ($tt eq 'backup') { > next if defined($vmid) && $fn !~ m/\S+-$vmid-\S+/; > next if $fn !~ m!/([^/]+\.(tgz|(?:(?:tar|vma)(?:\.(${\COMPRESSOR_= RE}))?)))$!; > + my $original =3D $fn; > my $format =3D $2; > $fn =3D $1; > $info =3D { volid =3D> "$sid:backup/$fn", format =3D> $format }; > @@ -1020,6 +1033,16 @@ my $get_subdir_files =3D sub { > $info->{vmid} =3D $vmid // $1; > } > =20 > + my $comment_fn =3D $original.COMMENT_EXT; > + if (!defined($has_comment->{$original})) { > + $has_comment->{$original} =3D (-f $comment_fn); > + } > + > + if ($has_comment->{$original}) { > + my $comment =3D PVE::Tools::file_read_firstline($comment_fn); > + $info->{comment} =3D $comment if defined($comment); > + } > + > } elsif ($tt eq 'snippets') { > =20 > $info =3D { >=20