]> git.proxmox.com Git - pve-storage.git/commitdiff
Added "nowritecache" option to ZFS storage plugin. Turns off write caching on Comstar...
authorChris Allen <Chris Allen>
Mon, 10 Mar 2014 19:07:35 +0000 (12:07 -0700)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 25 Jun 2014 07:13:03 +0000 (09:13 +0200)
Signed-off-by: Chris Allen <Chris Allen>
PVE/Storage/LunCmd/Comstar.pm
PVE/Storage/LunCmd/Istgt.pm
PVE/Storage/ZFSPlugin.pm

index 45ad6a583dd31b2526923250e81d40ea0cca6f42..aa1c61439ab4246affd47d66fc743508ef8bdc57 100644 (file)
@@ -50,11 +50,15 @@ sub run_lun_command {
     };
 
     if ($method eq 'create_lu') {
+        my $wcd = 'false'; 
+        if ($scfg->{nowritecache}) {
+          $wcd = 'true';
+       }
         my $prefix = '600144f';
         my $digest = md5_hex($params[0]);
         $digest =~ /(\w{7}(.*))/;
         $guid = "$prefix$2";
-        @params = ('-p', 'wcd=false', '-p', "guid=$guid", @params);
+        @params = ('-p', "wcd=$wcd", '-p', "guid=$guid", @params);
     } elsif ($method eq 'modify_lu') {
         @params = ('-s', @params);
     } elsif ($method eq 'list_view') {
index 9bbdfa00ff0a494a8efa592a5a48f34c4ba159ee..b386b5d7b455c91907395947137629c3102c5015 100644 (file)
@@ -173,6 +173,11 @@ my $lun_dumper = sub {
     foreach my $conf (@{$SETTINGS->{$lun}->{luns}}) {
         $config .=  "$conf->{lun} Storage " . $conf->{Storage};
         $config .= ' ' . $size_with_unit->($conf->{Size}) . "\n";
+        foreach ($conf->{options}) {
+            if ($_) {
+                $config .=  "$conf->{lun} Option " . $_ . "\n";
+            }
+        }
     }
     $config .= "\n";
 
@@ -228,16 +233,21 @@ my $free_lu_name = sub {
 };
 
 my $make_lun = sub {
-    my ($path) = @_;
+    my ($scfg, $path) = @_;
 
     my $target = $SETTINGS->{current};
     die 'Maximum number of LUNs per target is 63' if scalar @{$SETTINGS->{$target}->{luns}} >= $MAX_LUNS;
 
+    my @options = ();
     my $lun = $get_lu_name->($target);
+    if ($scfg->{nowritecache}) {
+        push @options, "WriteCache Disable";     
+    }
     my $conf = {
         lun => $lun,
         Storage => $path,
         Size => 'AUTO',
+        options => @options,
     };
     push @{$SETTINGS->{$target}->{luns}}, $conf;
 
@@ -274,7 +284,7 @@ my $parser = sub {
         } elsif ($lun) {
             next if (($_ =~ /^\s*#/) || ($_ =~ /^\s*$/));
             if ($_ =~ /^\s*(\w+)\s+(.+)\s*/) {
-                #next if $2 =~ /^Option.*/;
+                next if $2 =~ /^Option.*/;
                 $SETTINGS->{$lun}->{$1} = $2;
                 $SETTINGS->{$lun}->{$1} =~ s/^\s+|\s+$|"\s*//g;
             } else {
@@ -349,7 +359,7 @@ my $create_lun = sub {
         die "$params[0]: LUN exists";
     }
     my $lun = $params[0];
-    $lun = $make_lun->($lun);
+    $lun = $make_lun->($scfg, $lun);
     my $config = $lun_dumper->($SETTINGS->{current});
     open(my $fh, '>', $file) or die "Could not open file '$file' $!";
 
index 2d422d7b853b9e3c6040535e38ffba32f2b4c48b..302d2d608091fe6958f071cfb3b2e29004303e13 100644 (file)
@@ -328,10 +328,16 @@ sub properties {
         description => "block size",
         type => 'string',
     },
+    # this will disable write caching on comstar and istgt.
+    # it is not implemented for iet. iet blockio always operates with 
+    # writethrough caching when not in readonly mode
+    nowritecache => {
+        description => "disable write caching on the target",
+        type => 'boolean',
+    },
     sparse => {
         description => "use sparse volumes",
         type => 'boolean',
-       optional => 1,
     }
     };
 }
@@ -345,6 +351,7 @@ sub options {
     pool => { fixed => 1 },
     blocksize => { fixed => 1 },
     iscsiprovider => { fixed => 1 },
+    nowritecache => { optional => 1 },
     sparse => { optional => 1 },
     content => { optional => 1 },
     };