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 D18BF665E2 for ; Fri, 6 Nov 2020 12:25:13 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CAA75208F5 for ; Fri, 6 Nov 2020 12:24:43 +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 D54CC208D5 for ; Fri, 6 Nov 2020 12:24:42 +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 9D28145AD2 for ; Fri, 6 Nov 2020 12:24:42 +0100 (CET) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Fri, 6 Nov 2020 12:24:24 +0100 Message-Id: <20201106112425.8282-4-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106112425.8282-1-s.ivanov@proxmox.com> References: <20201106112425.8282-1-s.ivanov@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.095 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lxc.pm] Subject: [pve-devel] [PATCH container v2 1/2] add fsfreeze helper: 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: Fri, 06 Nov 2020 11:25:13 -0000 fsfreeze_mountpoint issues the same ioctl's as fsfreeze(8) on the provided directory (the $thaw parameter deciding between '--freeze' and '--unfreeze') This is used for container backups on RBD, where snapshots on containers, which are heavy on IO, are not mountable readonly, because the ext4 is not consistent Needed to fix #2991 and #2528. The ioctl numbers were found via strace -X verbose (and verified with the kernel documentation). Signed-off-by: Stoiko Ivanov --- src/PVE/LXC.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 9c150d9..ee86b37 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -35,6 +35,10 @@ use PVE::LXC::CGroup; use PVE::LXC::Monitor; use Time::HiRes qw (gettimeofday); + +use constant {FIFREEZE => 0xc0045877, + FITHAW => 0xc0045878}; + my $have_sdn; eval { require PVE::Network::SDN::Zones; @@ -1090,6 +1094,21 @@ my $get_container_namespace = sub { return $open_namespace->($vmid, $pid, $kind); }; +sub fsfreeze_mountpoint { + my ($path, $thaw) = @_; + + my $op = $thaw ? 'thaw' : 'freeze'; + my $ioctl = $thaw ? FITHAW : FIFREEZE; + + sysopen my $fd, $path, O_RDONLY or die "failed to open $path: $!\n"; + my $ioctl_err; + if (!ioctl($fd, $ioctl, 0)) { + $ioctl_err = "$!"; + } + close($fd); + die "fs$op '$path' failed - $ioctl_err\n" if defined $ioctl_err; +} + my $do_syncfs = sub { my ($vmid, $pid, $socket) = @_; -- 2.20.1