Hello Saggi Mizrahi, Dan Kenigsberg, Noam Slomianko,
I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/8174
to review the following change.
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]>
Reviewed-on: http://gerrit.ovirt.org/8143
Tested-by: Noam Slomianko <[email protected]>
Reviewed-by: Dan Kenigsberg <[email protected]>
---
M vdsm/storage/fileUtils.py
1 file changed, 6 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/8174/1
diff --git a/vdsm/storage/fileUtils.py b/vdsm/storage/fileUtils.py
index 020f16d..511dff9 100644
--- a/vdsm/storage/fileUtils.py
+++ b/vdsm/storage/fileUtils.py
@@ -45,8 +45,9 @@
log = logging.getLogger('fileUtils')
-PAGESIZE = libc.getpagesize()
CharPointer = ctypes.POINTER(ctypes.c_char)
+
+_PC_REC_XFER_ALIGN = 17
class TarCopyFailed(RuntimeError): pass
@@ -71,7 +72,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:
@@ -262,7 +264,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/8174
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If9da41a2f74d3cea7300df9606c78eebcc9927a9
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.1
Gerrit-Owner: Federico Simoncelli <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Noam Slomianko <[email protected]>
Gerrit-Reviewer: Saggi Mizrahi <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches