[pve-devel] [PATCH storage 1/1] add check for fsfreeze before snapshot

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Nov 5 19:00:32 CET 2020


On 05.11.20 17:06, Stoiko Ivanov wrote:
> In order to take a snapshot of a container volume, which can be mounted
> read-only with RBD, the volume needs to be frozen (fsfreeze (8)) before taking
> the snapshot. Only RBD is affected by this (for LVMThin this is handled
> by the devicemapper).
> 
> This commit adds helpers to determine if the FIFREEZE ioctl needs to be called
> for the volume.
> 
> Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
> ---
>  PVE/Storage.pm           | 12 ++++++++++++
>  PVE/Storage/Plugin.pm    |  4 ++++
>  PVE/Storage/RBDPlugin.pm |  5 +++++
>  3 files changed, 21 insertions(+)
> 
> diff --git a/PVE/Storage.pm b/PVE/Storage.pm
> index cd7b5ff..27223b6 100755
> --- a/PVE/Storage.pm
> +++ b/PVE/Storage.pm
> @@ -287,6 +287,18 @@ sub volume_snapshot_delete {
>      }
>  }
>  
> +# check if a filesystem on top of a volume needs to flush it's journal for
> +# constency (see fsfreeze(8)) before a snapshot is taken - needed for
> +# container mountpoints
> +sub volume_snapshot_needs_fsfreeze {
> +    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_needs_fsfreeze();
> +}
> +
>  # check if a volume or snapshot supports a given feature
>  # $feature - one of:
>  #            clone - linked clone is possible
> diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
> index 63f68da..a046640 100644
> --- a/PVE/Storage/Plugin.pm
> +++ b/PVE/Storage/Plugin.pm
> @@ -888,6 +888,10 @@ sub volume_snapshot_delete {
>      return undef;
>  }
>  
> +sub volume_snapshot_needs_fsfreeze {

expanding the storage plugin ABI should normally be recorded via the version/
age mechanism. New additions which do not break existing plugins should bump
both, max age and version. Else, external plugins cannot know if they can rely
on that method.

> +
> +    return 0;
> +}
>  sub storage_can_replicate {
>      my ($class, $scfg, $storeid, $format) = @_;
>  
> diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
> index 38f2b46..94df89d 100644
> --- a/PVE/Storage/RBDPlugin.pm
> +++ b/PVE/Storage/RBDPlugin.pm
> @@ -694,6 +694,11 @@ sub volume_snapshot_delete {
>      return undef;
>  }
>  
> +sub volume_snapshot_needs_fsfreeze {
> +
> +    return 1;
> +}
> +
>  sub volume_has_feature {
>      my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
>  
> 






More information about the pve-devel mailing list