From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 1/3] plugin: add volume_snapshot_info function
Date: Tue, 19 Oct 2021 09:54:50 +0200 [thread overview]
Message-ID: <20211019075459.14328-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20211019075459.14328-1-f.ebner@proxmox.com>
which allows for better choices of common replication snapshots.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
If this is applied without the following patches, it still needs an
APIVER+APIAGE bump and API changelog entry.
PVE/Storage.pm | 9 +++++++++
PVE/Storage/Plugin.pm | 10 ++++++++++
PVE/Storage/ZFSPoolPlugin.pm | 22 ++++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index e314bfc..f9582d0 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -371,6 +371,15 @@ sub volume_has_feature {
}
}
+sub volume_snapshot_info {
+ my ($cfg, $volid) = @_;
+
+ my ($storeid, $volname) = parse_volume_id($volid);
+ my $scfg = storage_config($cfg, $storeid);
+ my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
+ return $plugin->volume_snapshot_info($scfg, $storeid, $volname);
+}
+
sub volume_snapshot_list {
my ($cfg, $volid) = @_;
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index e1f9335..d4b3615 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -1212,6 +1212,16 @@ sub status {
return ($res->{total}, $res->{avail}, $res->{used}, 1);
}
+# Returns a hash with the snapshot names as keys and the following data:
+# id - Unique id to distinguish different snapshots even if the have the same name.
+# timestamp - Creation time of the snapshot (seconds since epoch).
+# Returns an empty hash if the volume does not exist.
+sub volume_snapshot_info {
+ my ($class, $scfg, $storeid, $volname) = @_;
+
+ die "volume_snapshot_info is not implemented for $class";
+}
+
sub volume_snapshot_list {
my ($class, $scfg, $storeid, $volname) = @_;
diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index b73d895..01d0743 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -510,6 +510,28 @@ sub volume_rollback_is_possible {
return 1;
}
+sub volume_snapshot_info {
+ my ($class, $scfg, $storeid, $volname) = @_;
+
+ my $vname = ($class->parse_volname($volname))[1];
+
+ my @params = ('-Hp', '-t', 'snapshot', '-o', 'name,guid,creation', "$scfg->{pool}\/$vname");
+ my $text = $class->zfs_request($scfg, undef, 'list', @params);
+ my @lines = split(/\n/, $text);
+
+ my $info = {};
+ for my $line (@lines) {
+ my ($snapshot, $guid, $creation) = split(/\s+/, $line);
+ (my $snap_name = $snapshot) =~ s/^.*@//;
+
+ $info->{$snap_name} = {
+ id => $guid,
+ timestamp => $creation,
+ };
+ }
+ return $info;
+}
+
sub volume_snapshot_list {
my ($class, $scfg, $storeid, $volname) = @_;
--
2.30.2
next prev parent reply other threads:[~2021-10-19 7:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 7:54 [pve-devel] [PATCH-SERIES storage/guest-common/manager] Follow-up for fixing replication/rollback interaction Fabian Ebner
2021-10-19 7:54 ` Fabian Ebner [this message]
2021-10-19 7:54 ` [pve-devel] [PATCH storage 2/3] plugin: remove volume_snapshot_list Fabian Ebner
2021-10-19 7:54 ` [pve-devel] [PATCH storage 3/3] bump APIVER and APIAGE Fabian Ebner
2021-10-19 7:54 ` [pve-devel] [PATCH guest-common 1/4] replication: refactor finding most recent common replication snapshot Fabian Ebner
2021-10-19 7:54 ` [pve-devel] [PATCH guest-common 2/4] replication: prepare: return additional information about snapshots Fabian Ebner
2021-10-19 7:54 ` [pve-devel] [PATCH guest-common 3/4] replication: find common snapshot: use additional information Fabian Ebner
2021-10-19 7:54 ` [pve-devel] [RFC guest-common 4/4] config: snapshot delete check: use volume_snapshot_info Fabian Ebner
2021-10-19 7:54 ` [pve-devel] [PATCH manager 1/3] test: replication: avoid implicit return for volume_snapshot Fabian Ebner
2021-10-19 7:54 ` [pve-devel] [PATCH manager 2/3] test: replication: mock volume_snapshot_info Fabian Ebner
2021-10-19 7:54 ` [pve-devel] [PATCH manager 3/3] test: replication: remove mocking for obsolete volume_snapshot_list Fabian Ebner
2021-11-09 16:50 ` [pve-devel] applied-series: [PATCH-SERIES storage/guest-common/manager] Follow-up for fixing replication/rollback interaction Fabian Grünbichler
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=20211019075459.14328-2-f.ebner@proxmox.com \
--to=f.ebner@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