Skip to content

Commit 93a94f5

Browse files
kk7dsianw
authored andcommitted
Enable direct-io on LVM loop devices
This enables direct-io on the loop devices that we create for LVM backing stores. The goal here is to reduce the buffer cache overhead involved with loop mounting a very large file on a filesystem, as well as potentially providing a little more block-device-like behavior for things that expect them. We are hoping this will address some of the very long LVM calls that cinder does, which randomly take a very long time, causing timeouts. The loop direct-io support was added in kernel 4.4.0, which was xenial, but the losetup binary does not have the required flag. Thus, this patch checks the "losetup -h" output for the flag before deciding to enable it. Change-Id: Idc69cf3598d6ed6646c0145733c90ad0b1b60883
1 parent 8fc227f commit 93a94f5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

lib/lvm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,15 @@ function _create_lvm_volume_group {
9999
if ! sudo vgs $vg; then
100100
# Only create if the file doesn't already exists
101101
[[ -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+
102109
local vg_dev
103-
vg_dev=`sudo losetup -f --show $backing_file`
110+
vg_dev=$(sudo losetup -f --show $directio $backing_file)
104111

105112
# Only create volume group if it doesn't already exist
106113
if ! sudo vgs $vg; then

0 commit comments

Comments
 (0)