Saggi Mizrahi has uploaded a new change for review.

Change subject: Use the recommended alignment instead of using pagesize
......................................................................

Use the recommended alignment instead of using pagesize

Page size is the usual recommended alignment but when it isn't using it
can cause memory corruption.

Change-Id: If9da41a2f74d3cea7300df9606c78eebcc9927a9
Signed-off-by: Saggi Mizrahi <[email protected]>
---
M vdsm/storage/fileUtils.py
1 file changed, 6 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/43/8143/1

diff --git a/vdsm/storage/fileUtils.py b/vdsm/storage/fileUtils.py
index b8bbb31..80c45e9 100644
--- a/vdsm/storage/fileUtils.py
+++ b/vdsm/storage/fileUtils.py
@@ -44,8 +44,9 @@
 
 log = logging.getLogger('fileUtils')
 
-PAGESIZE = libc.getpagesize()
 CharPointer = ctypes.POINTER(ctypes.c_char)
+
+_PC_REC_XFER_ALIGN = 17
 
 
 class TarCopyFailed(RuntimeError):
@@ -78,7 +79,8 @@
         os.listdir(path)
     except OSError as ex:
         if ex.errno in (errno.EIO, errno.ESTALE):
-            return  True
+            return True
+
         # We could get contradictory results because of
         # soft mounts
         if (exists or st) and ex.errno == errno.ENOENT:
@@ -293,7 +295,8 @@
         ppbuff = ctypes.pointer(pbuff)
         # Because we usually have fixed sizes for our reads, caching
         # buffers might give a slight performance boost.
-        rc = libc.posix_memalign(ppbuff, PAGESIZE, size)
+        alignment = libc.fpathconf(self.fileno(), _PC_REC_XFER_ALIGN)
+        rc = libc.posix_memalign(ppbuff, alignment, size)
         if rc:
             raise OSError(rc, "Could not allocate aligned buffer")
         try:


--
To view, visit http://gerrit.ovirt.org/8143
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If9da41a2f74d3cea7300df9606c78eebcc9927a9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to