Change in vdsm[ovirt-3.1]: Use buffer size in multiplies of the recommended transfer si...

fsimonce at redhat.com fsimonce at redhat.com
Thu Oct 4 20:29:24 UTC 2012


Hello Jason Brooks, Saggi Mizrahi, Dan Kenigsberg,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/8369

to review the following change.

Change subject: Use buffer size in multiplies of the recommended transfer size
......................................................................

Use buffer size in multiplies of the recommended transfer size

Using the recommended transfer size fixes the memory corruption for NFS.

Bug-Id: http://bugzilla.redhat.com/845660
Change-Id: Iadea310039b30073197b7ad90afb930c460bda17
Signed-off-by: Saggi Mizrahi <smizrahi at redhat.com>
Reviewed-on: http://gerrit.ovirt.org/8356
Reviewed-by: Dan Kenigsberg <danken at redhat.com>
Tested-by: Jason Brooks <jbrooks at redhat.com>
---
M vdsm/storage/fileUtils.py
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/69/8369/1

diff --git a/vdsm/storage/fileUtils.py b/vdsm/storage/fileUtils.py
index 511dff9..ccc2bfe 100644
--- a/vdsm/storage/fileUtils.py
+++ b/vdsm/storage/fileUtils.py
@@ -48,6 +48,7 @@
 CharPointer = ctypes.POINTER(ctypes.c_char)
 
 _PC_REC_XFER_ALIGN = 17
+_PC_REC_MIN_XFER_SIZE = 16
 
 class TarCopyFailed(RuntimeError): pass
 
@@ -265,6 +266,13 @@
         # Because we usually have fixed sizes for our reads, caching
         # buffers might give a slight performance boost.
         alignment = libc.fpathconf(self.fileno(), _PC_REC_XFER_ALIGN)
+        minXferSize = libc.fpathconf(self.fileno(), _PC_REC_MIN_XFER_SIZE)
+        chunks, remainder = divmod(size, minXferSize)
+        if remainder > 0:
+            chunks += 1
+
+        size = chunks * minXferSize
+
         rc = libc.posix_memalign(ppbuff, alignment, size)
         if rc:
             raise OSError(rc, "Could not allocate aligned buffer")


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iadea310039b30073197b7ad90afb930c460bda17
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.1
Gerrit-Owner: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Jason Brooks <jbrooks at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>


More information about the vdsm-patches mailing list