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 compared with the kernel source). Signed-off-by: Stoiko Ivanov <s.iva...@proxmox.com> --- src/PVE/Tools.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm index 4b445ea..c61fc49 100644 --- a/src/PVE/Tools.pm +++ b/src/PVE/Tools.pm @@ -100,6 +100,9 @@ use constant {O_PATH => 0x00200000, use constant {AT_EMPTY_PATH => 0x1000, AT_FDCWD => -100}; +use constant {FIFREEZE => 0xc0045877, + FITHAW => 0xc0045878}; + sub run_with_timeout { my ($timeout, $code, @param) = @_; @@ -1442,6 +1445,21 @@ sub sync_mountpoint { die "syncfs '$path' failed - $syncfs_err\n" if defined $syncfs_err; } +sub fsfreeze_mountpoint { + my ($path, $thaw) = @_; + + my $op = $thaw ? 'thaw' : 'freeze'; + my $ioctl = $thaw ? FITHAW : FIFREEZE; + + sysopen my $fd, $path, O_RDONLY|O_CLOEXEC 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; +} + # support sending multi-part mail messages with a text and or a HTML part # mailto may be a single email string or an array of receivers sub sendmail { -- 2.20.1 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel