summaryrefslogtreecommitdiff
path: root/src/SingleFileAllocationIterator.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-12-06 12:32:27 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2007-12-06 12:32:27 +0000
commit68579bd2f4284ba9128cb972f8edaace03d466e5 (patch)
treeb1784b4bd10d6c04b78f68097374236442f09e7f /src/SingleFileAllocationIterator.cc
parent30739b0763bb922d12e1616a2c8ce603bc80814d (diff)
2007-12-06 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Changed Direct/IO enable/disable procesure in file allocation routine. * src/SingleFileAllocationIterator.cc (SingleFileAllocationIterator): Disable directIO if offset is not multiple of 512. (~SingleFileAllocationIterator): Removed a call to disableDirectIO. * src/MultiFileAllocationIterator.cc (allocateChunk): Enable created SingleFileAllocationIterator's directIO. * src/FileAllocationEntry.cc (FileAllocationEntry): Enable directIO here. (~FileAllocationEntry): Disable directIO here.
Diffstat (limited to 'src/SingleFileAllocationIterator.cc')
-rw-r--r--src/SingleFileAllocationIterator.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/SingleFileAllocationIterator.cc b/src/SingleFileAllocationIterator.cc
index ae6d513e..e71e16eb 100644
--- a/src/SingleFileAllocationIterator.cc
+++ b/src/SingleFileAllocationIterator.cc
@@ -38,24 +38,24 @@
#include "a2io.h"
#define BUFSIZE (256*1024)
+#define ALIGNMENT 512
SingleFileAllocationIterator::SingleFileAllocationIterator(BinaryStream* stream, int64_t offset, int64_t totalLength):_stream(stream), _offset(offset), _totalLength(totalLength), _buffer(0)
{
- if(_offset%512 == 0) {
- _stream->enableDirectIO();
+ if(_offset%ALIGNMENT != 0) {
+ _stream->disableDirectIO();
}
}
SingleFileAllocationIterator::~SingleFileAllocationIterator()
{
delete [] _buffer;
- _stream->disableDirectIO();
}
void SingleFileAllocationIterator::init()
{
#ifdef HAVE_POSIX_MEMALIGN
- _buffer = (unsigned char*)Util::allocateAlignedMemory(512, BUFSIZE);
+ _buffer = (unsigned char*)Util::allocateAlignedMemory(ALIGNMENT, BUFSIZE);
#else
_buffer = new unsigned char[BUFSIZE];
#endif // HAVE_POSIX_MEMALIGN