public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Friedrich Weber <f.weber@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH container] fix #4470: pct fstrim: ignore bind or read-only mountpoints
Date: Mon, 20 Feb 2023 11:04:45 +0100	[thread overview]
Message-ID: <20230220100445.1912573-1-f.weber@proxmox.com> (raw)

Currently, `pct fstrim` will run `fstrim` on all mountpoints
of the container, including bind and read-only mountpoints.

However, trimming a bind mountpoint might trim a host
filesystem, which users may not expect. Also, trimming can
be considered a write operation, which users may not expect
to be carried out on a read-only mountpoint.

Hence, exclude bind mointpoints and read-only mountpoints
from trimming.

Signed-off-by: Friedrich Weber <f.weber@proxmox.com>
---
 src/PVE/CLI/pct.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index 3ade2ba..d559d00 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -763,7 +763,7 @@ __PACKAGE__->register_method ({
     name => 'fstrim',
     path => 'fstrim',
     method => 'POST',
-    description => "Run fstrim on a chosen CT and its mountpoints.",
+    description => "Run fstrim on a chosen CT and its mountpoints, except bind or read-only mountpoints.",
     parameters => {
 	additionalProperties => 0,
 	properties => {
@@ -791,6 +791,7 @@ __PACKAGE__->register_method ({
 	    PVE::LXC::Config->foreach_volume($conf, sub {
 		my ($name, $mp) = @_;
 		$path = $mp->{mp};
+		return if $mp->{type} eq 'bind' || $mp->{ro};
 		return if $param->{'ignore-mountpoints'} && $name =~ /^mp\d+/;
 		my $cmd = ["fstrim", "-v", "$rootdir$path"];
 		PVE::Tools::run_command($cmd, noerr => 1);
-- 
2.30.2





             reply	other threads:[~2023-02-20 10:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-20 10:04 Friedrich Weber [this message]
2023-02-20 10:30 ` [pve-devel] applied: " Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230220100445.1912573-1-f.weber@proxmox.com \
    --to=f.weber@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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