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 8437D63C6B for ; Wed, 28 Oct 2020 17:16:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 77F7D21F78 for ; Wed, 28 Oct 2020 17:16:41 +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 5D83321F6C for ; Wed, 28 Oct 2020 17:16:40 +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 2958E45F72 for ; Wed, 28 Oct 2020 17:16:40 +0100 (CET) To: Proxmox VE development discussion , Oguz Bektas References: <20201028111135.226496-1-o.bektas@proxmox.com> From: Thomas Lamprecht Message-ID: <1f81eb46-d7fc-c22e-fc82-318d2f0e69b9@proxmox.com> Date: Wed, 28 Oct 2020 17:16:39 +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: <20201028111135.226496-1-o.bektas@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.958 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 -2.167 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. [pct.pm] Subject: Re: [pve-devel] [PATCH container] pct fstrim: add 'ignore_mp' parameter 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: Wed, 28 Oct 2020 16:16:41 -0000 On 28.10.20 12:11, Oguz Bektas wrote: > parameter to ignore mountpoints when doing fstrim on a container >=20 > root@pve:~# pct fstrim 123 --ignore_mp > /var/lib/lxc/123/rootfs/: 0 B (0 bytes) trimmed > root@pve:~# pct fstrim 123 > /var/lib/lxc/123/rootfs/: 0 B (0 bytes) trimmed > /var/lib/lxc/123/rootfs/test: 321.1 MiB (336654336 bytes) trimmed >=20 > Signed-off-by: Oguz Bektas > --- > src/PVE/CLI/pct.pm | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) >=20 > diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm > index df4e9f8..056ae78 100755 > --- a/src/PVE/CLI/pct.pm > +++ b/src/PVE/CLI/pct.pm > @@ -767,6 +767,10 @@ __PACKAGE__->register_method ({ > additionalProperties =3D> 0, > properties =3D> { > vmid =3D> get_standard_option('pve-vmid', { completion =3D> \&PVE= ::LXC::complete_ctid }), > + ignore_mp =3D> { 1. new parameters are prefer as kebab-case, at least if that command prov= ides no other casing/separation variants in its options. 2. no description -> NAK > + optional =3D> 1, > + type =3D> 'boolean', > + }, > }, > }, > returns =3D> { type =3D> 'null' }, > @@ -785,11 +789,16 @@ __PACKAGE__->register_method ({ > PVE::LXC::Config->foreach_volume($conf, sub { > my ($name, $mp) =3D @_; > $path =3D $mp->{mp}; > + if ($param->{ignore_mp}) { > + return if $name =3D~ '^mp[0-9]*'; why is the regex in a string, not a // and why * ? Could be also just: return if $param->{'ignore-mountpoints'} && $name =3D~ /^mp\d+/; but no hard feelings here. > + } > my $cmd =3D ["fstrim", "-v", "$rootdir$path"]; > PVE::Tools::run_command($cmd); > }); > }; > - warn $@ if $@; > + if (my $err =3D $@) { > + warn $err; > + } not neded for this patch, and not really a improvement, the `warn $@ if $= @;` is quite widely used, and not considered as "bad", IIRC. > =20 > PVE::LXC::umount_all($vmid, $storecfg, $conf, 0); > PVE::LXC::Config->remove_lock($vmid, 'fstrim'); >=20