]> git.proxmox.com Git - pve-container.git/commitdiff
Fix mounting ZFS snapshots whose dataset is not mounted below '/'
authorFabian Ebner <f.ebner@proxmox.com>
Tue, 18 Feb 2020 11:31:22 +0000 (12:31 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 4 Mar 2020 14:18:03 +0000 (15:18 +0100)
Trying to back up a container with a ZFS dataset with non-standard mount
would fail, see [0].

This also removes the near-dead code
$name .= "\@$snapname";
when snapname is false-y, but defined and turns
the check for $snapname into one for definedness.

[0]: https://forum.proxmox.com/threads/lxc-backup-fails-unable-to-open-the-dataset-vzdump.64944/

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
src/PVE/LXC.pm

index 34ca2a357294f63e8b49d965bd54c24905642e17..21bc9c649d3972755ba82b5d5c46b5457fbb110e 100644 (file)
@@ -1647,19 +1647,17 @@ sub __mountpoint_mount {
 
        if ($format eq 'subvol') {
            if ($mount_path) {
-               if ($snapname) {
+               my (undef, $name) = PVE::Storage::parse_volname($storage_cfg, $volid);
+               if (defined($snapname)) {
+                   $name .= "\@$snapname";
                    if ($scfg->{type} eq 'zfspool') {
-                       my $path_arg = $path;
-                       $path_arg =~ s!^/+!!;
-                       PVE::Tools::run_command(['mount', '-o', 'ro', @extra_opts, '-t', 'zfs', $path_arg, $mount_path]);
+                       PVE::Tools::run_command(['mount', '-o', 'ro', @extra_opts, '-t', 'zfs', "$scfg->{pool}/$name", $mount_path]);
                    } else {
                        die "cannot mount subvol snapshots for storage type '$scfg->{type}'\n";
                    }
                } else {
                    if (defined($acl) && $scfg->{type} eq 'zfspool') {
                        my $acltype = ($acl ? 'acltype=posixacl' : 'acltype=noacl');
-                       my (undef, $name) = PVE::Storage::parse_volname($storage_cfg, $volid);
-                       $name .= "\@$snapname" if defined($snapname);
                        PVE::Tools::run_command(['zfs', 'set', $acltype, "$scfg->{pool}/$name"]);
                    }
                    bindmount($path, $parentfd, $last_dir//$rootdir, $mount_path, $readonly, @extra_opts);