Browse code

Merge "Enable direct-io on LVM loop devices"

Zuul authored on 2018/12/17 11:15:14
Showing 1 changed files
... ...
@@ -99,8 +99,15 @@ function _create_lvm_volume_group {
99 99
     if ! sudo vgs $vg; then
100 100
         # Only create if the file doesn't already exists
101 101
         [[ -f $backing_file ]] || truncate -s $size $backing_file
102
+
103
+        local directio=""
104
+        # Check to see if we can do direct-io
105
+        if losetup -h | grep -q direct-io; then
106
+            directio="--direct-io=on"
107
+        fi
108
+
102 109
         local vg_dev
103
-        vg_dev=`sudo losetup -f --show $backing_file`
110
+        vg_dev=$(sudo losetup -f --show $directio $backing_file)
104 111
 
105 112
         # Only create volume group if it doesn't already exist
106 113
         if ! sudo vgs $vg; then