From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common] add fsfreeze helper:
Date: Thu, 5 Nov 2020 17:06:29 +0100 [thread overview]
Message-ID: <20201105160631.26834-2-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20201105160631.26834-1-s.ivanov@proxmox.com>
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.ivanov@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
next prev parent reply other threads:[~2020-11-05 16:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 16:06 [pve-devel] [PATCH common/storage/container] add fsfreeze/thaw for rbd snapshots Stoiko Ivanov
2020-11-05 16:06 ` Stoiko Ivanov [this message]
2020-11-05 16:06 ` [pve-devel] [PATCH storage 1/1] add check for fsfreeze before snapshot Stoiko Ivanov
2020-11-05 18:00 ` Thomas Lamprecht
2020-11-05 16:06 ` [pve-devel] [PATCH container 1/1] snapshot creation: fsfreeze mountpoints, if needed Stoiko Ivanov
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=20201105160631.26834-2-s.ivanov@proxmox.com \
--to=s.ivanov@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.