public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container] pct fstrim: add 'ignore_mp' parameter
@ 2020-10-28 11:11 Oguz Bektas
  2020-10-28 16:16 ` Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Oguz Bektas @ 2020-10-28 11:11 UTC (permalink / raw)
  To: pve-devel

parameter to ignore mountpoints when doing fstrim on a container

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

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---
 src/PVE/CLI/pct.pm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

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 => 0,
 	properties => {
 	    vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
+	    ignore_mp => {
+		optional => 1,
+		type => 'boolean',
+	    },
 	},
     },
     returns => { type => 'null' },
@@ -785,11 +789,16 @@ __PACKAGE__->register_method ({
 	    PVE::LXC::Config->foreach_volume($conf, sub {
 		my ($name, $mp) = @_;
 		$path = $mp->{mp};
+		if ($param->{ignore_mp}) {
+		    return if $name =~ '^mp[0-9]*';
+		}
 		my $cmd = ["fstrim", "-v", "$rootdir$path"];
 		PVE::Tools::run_command($cmd);
 	    });
 	};
-	warn $@ if $@;
+	if (my $err = $@) {
+	    warn $err;
+	}
 
 	PVE::LXC::umount_all($vmid, $storecfg, $conf, 0);
 	PVE::LXC::Config->remove_lock($vmid, 'fstrim');
-- 
2.20.1




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-28 16:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 11:11 [pve-devel] [PATCH container] pct fstrim: add 'ignore_mp' parameter Oguz Bektas
2020-10-28 16:16 ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal