Change in vdsm[master]: fileUtils: Remove the redundant "d" mode

nsoffer at redhat.com nsoffer at redhat.com
Sat Mar 12 02:22:57 UTC 2016


Nir Soffer has uploaded a new change for review.

Change subject: fileUtils: Remove the redundant "d" mode
......................................................................

fileUtils: Remove the redundant "d" mode

When creating a DirectFile, the only available mode is directio, so the
non-standard "d" mode is not helpful, and error checking can be
simplified.

Change-Id: I23be87699af290bb20381219fe32d06bb79ba9b5
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M tests/fileUtilTests.py
M vdsm/storage/fileUtils.py
M vdsm/storage/remoteFileHandler.py
3 files changed, 7 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/80/54680/1

diff --git a/tests/fileUtilTests.py b/tests/fileUtilTests.py
index 8c2622e..032568f 100644
--- a/tests/fileUtilTests.py
+++ b/tests/fileUtilTests.py
@@ -36,26 +36,26 @@
     @permutations([[0], [512], [1024], [1024 + 512]])
     def testRead(self, size):
         with temporaryPath(data=self.DATA) as srcPath, \
-                fileUtils.DirectFile(srcPath, "dr") as f:
+                fileUtils.DirectFile(srcPath, "r") as f:
             self.assertEquals(f.read(size), self.DATA[:size])
 
     @permutations([[512], [1024]])
     def testSeekRead(self, offset):
         with temporaryPath(data=self.DATA) as srcPath, \
-                fileUtils.DirectFile(srcPath, "dr") as f:
+                fileUtils.DirectFile(srcPath, "r") as f:
             f.seek(offset)
             self.assertEquals(f.read(), self.DATA[offset:])
 
     def testWrite(self):
         with temporaryPath() as srcPath, \
-                fileUtils.DirectFile(srcPath, "dw") as f:
+                fileUtils.DirectFile(srcPath, "w") as f:
             f.write(self.DATA)
             with open(srcPath) as f:
                 self.assertEquals(f.read(), self.DATA)
 
     def testSmallWrites(self):
         with temporaryPath() as srcPath, \
-                fileUtils.DirectFile(srcPath, "dw") as f:
+                fileUtils.DirectFile(srcPath, "w") as f:
             f.write(self.DATA[:512])
             f.write(self.DATA[512:])
 
@@ -64,10 +64,10 @@
 
     def testUpdateRead(self):
         with temporaryPath() as srcPath, \
-                fileUtils.DirectFile(srcPath, "wd") as f:
+                fileUtils.DirectFile(srcPath, "w") as f:
             f.write(self.DATA[:512])
 
-            with fileUtils.DirectFile(srcPath, "r+d") as f:
+            with fileUtils.DirectFile(srcPath, "r+") as f:
                 f.seek(512)
                 f.write(self.DATA[512:])
 
diff --git a/vdsm/storage/fileUtils.py b/vdsm/storage/fileUtils.py
index 697b6ce..fae4fef 100644
--- a/vdsm/storage/fileUtils.py
+++ b/vdsm/storage/fileUtils.py
@@ -196,12 +196,6 @@
 
 class DirectFile(object):
     def __init__(self, path, mode):
-        if "d" not in mode:
-            raise ValueError("This class only handles direct IO")
-
-        if len(mode) < 2:
-            raise ValueError("Invalid mode parameter")
-
         self._writable = True
         flags = os.O_DIRECT
 
diff --git a/vdsm/storage/remoteFileHandler.py b/vdsm/storage/remoteFileHandler.py
index e858c81..c92a4c4 100644
--- a/vdsm/storage/remoteFileHandler.py
+++ b/vdsm/storage/remoteFileHandler.py
@@ -334,7 +334,7 @@
 
 
 def directReadLines(path):
-    with fileUtils.DirectFile(path, "dr") as f:
+    with fileUtils.DirectFile(path, "r") as f:
         return f.readlines()
 
 


-- 
To view, visit https://gerrit.ovirt.org/54680
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23be87699af290bb20381219fe32d06bb79ba9b5
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list