]> git.proxmox.com Git - pve-storage.git/commitdiff
path based storages: improve the mkdir option
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 31 Aug 2016 08:29:08 +0000 (10:29 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 27 Sep 2016 07:54:53 +0000 (09:54 +0200)
So far this only prevented the creation of the toplevel
directory. This does not cover all problem cases,
particularly when said directory is supposed to be a mount
point, including NFS and glusterfs beside ZFS.

The directory based storages we have already use mkpath
whenever they need to create files, and for actions on files
which are supposed to exist it's fine if it errors out.
So it should also be safe to skip the creation of standard
subdirectories in activate_storage().

Additionally NFS and glusterfs storages should also accept
the mkdir option as they otherwise may exhibit similar
issues, eg. when an NFS storage is mounted onto a directory
inside a ZFS subvolume.

PVE/Storage/GlusterfsPlugin.pm
PVE/Storage/NFSPlugin.pm
PVE/Storage/Plugin.pm

index 951db50d3f76800930617d3ec129fec2f6f13e5e..1e63e24ae6783e4dd86238bed20eb73362bf1079 100644 (file)
@@ -135,6 +135,7 @@ sub options {
         maxfiles => { optional => 1 },
        content => { optional => 1 },
        format => { optional => 1 },
+       mkdir => { optional => 1 },
     };
 }
 
@@ -272,7 +273,7 @@ sub activate_storage {
 
     if (!glusterfs_is_mounted($volume, $path, $cache->{mountdata})) {
        
-       mkpath $path;
+       mkpath $path if !(defined($scfg->{mkdir}) && !$scfg->{mkdir});
 
        die "unable to activate storage '$storeid' - " .
            "directory '$path' does not exist\n" if ! -d $path;
index df00f373d2562a0b3e2b7b5144fe065ade5b1827..2f75eeec0721be3703dbc873568b04c451ad46f7 100644 (file)
@@ -85,6 +85,7 @@ sub options {
        options => { optional => 1 },
        content => { optional => 1 },
        format => { optional => 1 },
+       mkdir => { optional => 1 },
     };
 }
 
@@ -129,7 +130,7 @@ sub activate_storage {
        # NOTE: only call mkpath when not mounted (avoid hang 
        # when NFS server is offline 
                    
-       mkpath $path;
+       mkpath $path if !(defined($scfg->{mkdir}) && !$scfg->{mkdir});
 
        die "unable to activate storage '$storeid' - " .
            "directory '$path' does not exist\n" if ! -d $path;
index cdc89ba695b9ee17f60742678541fad72f7bbd4b..6e73547bcb2426a3afce0a8f95a8f82fe6ce0551 100644 (file)
@@ -834,6 +834,8 @@ sub activate_storage {
     die "unable to activate storage '$storeid' - " .
        "directory '$path' does not exist\n" if ! -d $path;
 
+    return if defined($scfg->{mkdir}) && !$scfg->{mkdir};
+
     if (defined($scfg->{content})) {
        foreach my $vtype (keys %$vtype_subdirs) {
            # OpenVZMigrate uses backup (dump) dir