File 0118-tcm-file-Set-fd_buffered_io-1-based-upon-active-FILE.patch of Package lio-utils.216
From 5d0f4829aa130619e81edad3fe0aaa697fa00be4 Mon Sep 17 00:00:00 2001
From: Nicholas Bellinger <nab@risingtidesystems.com>
Date: Thu, 31 Jan 2013 11:54:05 -0800
Subject: tcm-file: Set fd_buffered_io=1 based upon active FILEIO mode
This patch fixes a bug in fd_get_params() where FILEIO buffered enabled mode
was not being saved across reboots in /etc/target/tcm_start.sh, causing
FILEIO devices created with buffered=true to revert to O_DSYNC mode.
Signed-off-by: Nicholas Bellinger <nab@risingtidesystems.com>
---
tcm-py/tcm_fileio.py | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/tcm-py/tcm_fileio.py b/tcm-py/tcm_fileio.py
index c130bc6..7429844 100755
--- a/tcm-py/tcm_fileio.py
+++ b/tcm-py/tcm_fileio.py
@@ -50,15 +50,29 @@ def createvirtdev(path, params):
def fd_freevirtdev():
pass
+def fd_get_buffered_mode(value):
+
+ off = value.index(' Mode: ')
+ off += 7
+ fd_dev_mode_tmp = value[off:]
+ fd_dev_mode = fd_dev_mode_tmp.split(' ')
+ if re.search('Buffered', fd_dev_mode[0]):
+ fd_dev_mode_str = ",fd_buffered_io=1"
+ else:
+ fd_dev_mode_str = ""
+
+ return fd_dev_mode_str
+
def fd_get_params(path):
# Reference by udev_path if available
udev_path_file = path + "/udev_path"
p = os.open(udev_path_file, 0)
value = os.read(p, 1024)
if re.search('/dev/', value):
- os.close(p)
- # Append a FILEIO size of ' 0', as struct block_device sector count is autodetected by TCM
- return "fd_dev_name=" + value.rstrip() + ",fd_dev_size=0"
+ fd_dev_blockdev = 1
+ fd_dev_blockdev_str = "fd_dev_name=" + value.rstrip() + ",fd_dev_size=0"
+ else:
+ fd_dev_blockdev = 0
os.close(p)
@@ -71,6 +85,11 @@ def fd_get_params(path):
return
p.close()
+ if fd_dev_blockdev:
+ fd_dev_mode_str = fd_get_buffered_mode(value)
+ # Append a FILEIO size of ' 0', as struct block_device sector count is autodetected by TCM
+ return fd_dev_blockdev_str + fd_dev_mode_str
+
off = value.index('File: ')
off += 6
fd_dev_name_tmp = value[off:]
@@ -79,7 +98,10 @@ def fd_get_params(path):
off += 7
fd_dev_size_tmp = value[off:]
fd_dev_size = fd_dev_size_tmp.split(' ')
- params = "fd_dev_name=" + fd_dev_name[0] + ",fd_dev_size=" + fd_dev_size[0]
+
+ fd_dev_mode_str = fd_get_buffered_mode(value)
+
+ params = "fd_dev_name=" + fd_dev_name[0] + ",fd_dev_size=" + fd_dev_size[0] + fd_dev_mode_str
# fd_dev_name= and fd_dev_size= parameters for tcm_node --createdev
return params
--
1.8.1.4