mirror of https://github.com/aria2/aria2
2009-03-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Guarded #ifdef HAVE_POSIX_FALLOCATE * src/AbstractSingleDiskAdaptor.cc * src/DefaultPieceStorage.cc * src/DiskAdaptor.h * src/DiskAdaptor.h * src/MultiFileAllocationIterator.ccpull/1/head
parent
a69f499ccf
commit
6cbb6d2850
|
@ -1,3 +1,12 @@
|
||||||
|
2009-03-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Guarded #ifdef HAVE_POSIX_FALLOCATE
|
||||||
|
* src/AbstractSingleDiskAdaptor.cc
|
||||||
|
* src/DefaultPieceStorage.cc
|
||||||
|
* src/DiskAdaptor.h
|
||||||
|
* src/DiskAdaptor.h
|
||||||
|
* src/MultiFileAllocationIterator.cc
|
||||||
|
|
||||||
2009-03-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-03-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Run
|
Run
|
||||||
|
|
|
@ -35,7 +35,9 @@
|
||||||
#include "AbstractSingleDiskAdaptor.h"
|
#include "AbstractSingleDiskAdaptor.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "SingleFileAllocationIterator.h"
|
#include "SingleFileAllocationIterator.h"
|
||||||
#include "FallocFileAllocationIterator.h"
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
|
# include "FallocFileAllocationIterator.h"
|
||||||
|
#endif // HAVE_POSIX_FALLOCATE
|
||||||
#include "DiskWriter.h"
|
#include "DiskWriter.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -91,12 +93,14 @@ void AbstractSingleDiskAdaptor::truncate(uint64_t length)
|
||||||
|
|
||||||
FileAllocationIteratorHandle AbstractSingleDiskAdaptor::fileAllocationIterator()
|
FileAllocationIteratorHandle AbstractSingleDiskAdaptor::fileAllocationIterator()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
if(_fallocate) {
|
if(_fallocate) {
|
||||||
SharedHandle<FallocFileAllocationIterator> h
|
SharedHandle<FallocFileAllocationIterator> h
|
||||||
(new FallocFileAllocationIterator(this, size(), totalLength));
|
(new FallocFileAllocationIterator(this, size(), totalLength));
|
||||||
return h;
|
return h;
|
||||||
} else {
|
} else
|
||||||
|
#endif // HAVE_POSIX_FALLOCATE
|
||||||
|
{
|
||||||
SingleFileAllocationIteratorHandle h
|
SingleFileAllocationIteratorHandle h
|
||||||
(new SingleFileAllocationIterator(this, size(), totalLength));
|
(new SingleFileAllocationIterator(this, size(), totalLength));
|
||||||
h->init();
|
h->init();
|
||||||
|
|
|
@ -498,9 +498,11 @@ void DefaultPieceStorage::initStorage()
|
||||||
}
|
}
|
||||||
diskAdaptor->setStoreDir(downloadContext->getDir());
|
diskAdaptor->setStoreDir(downloadContext->getDir());
|
||||||
diskAdaptor->setFileEntries(downloadContext->getFileEntries());
|
diskAdaptor->setFileEntries(downloadContext->getFileEntries());
|
||||||
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
if(option->get(PREF_FILE_ALLOCATION) == V_FALLOC) {
|
if(option->get(PREF_FILE_ALLOCATION) == V_FALLOC) {
|
||||||
diskAdaptor->enableFallocate();
|
diskAdaptor->enableFallocate();
|
||||||
}
|
}
|
||||||
|
#endif // HAVE_POSIX_FALLOCATE
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPieceStorage::setBitfield(const unsigned char* bitfield,
|
void DefaultPieceStorage::setBitfield(const unsigned char* bitfield,
|
||||||
|
|
|
@ -43,7 +43,10 @@
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
DiskAdaptor::DiskAdaptor():
|
DiskAdaptor::DiskAdaptor():
|
||||||
_fallocate(false), logger(LogFactory::getInstance()) {}
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
|
_fallocate(false),
|
||||||
|
#endif // HAVE_POSIX_FALLOCATE
|
||||||
|
logger(LogFactory::getInstance()) {}
|
||||||
|
|
||||||
DiskAdaptor::~DiskAdaptor() {}
|
DiskAdaptor::~DiskAdaptor() {}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,9 @@ class DiskAdaptor:public BinaryStream {
|
||||||
protected:
|
protected:
|
||||||
std::string storeDir;
|
std::string storeDir;
|
||||||
std::deque<SharedHandle<FileEntry> > fileEntries;
|
std::deque<SharedHandle<FileEntry> > fileEntries;
|
||||||
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
bool _fallocate;
|
bool _fallocate;
|
||||||
|
#endif // HAVE_POSIX_FALLOCATE
|
||||||
Logger* logger;
|
Logger* logger;
|
||||||
public:
|
public:
|
||||||
DiskAdaptor();
|
DiskAdaptor();
|
||||||
|
@ -109,6 +111,7 @@ public:
|
||||||
// successfully changed.
|
// successfully changed.
|
||||||
virtual size_t utime(const Time& actime, const Time& modtime) = 0;
|
virtual size_t utime(const Time& actime, const Time& modtime) = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
void enableFallocate()
|
void enableFallocate()
|
||||||
{
|
{
|
||||||
_fallocate = true;
|
_fallocate = true;
|
||||||
|
@ -123,6 +126,7 @@ public:
|
||||||
{
|
{
|
||||||
return _fallocate;
|
return _fallocate;
|
||||||
}
|
}
|
||||||
|
#endif // HAVE_POSIX_FALLOCATE
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<DiskAdaptor> DiskAdaptorHandle;
|
typedef SharedHandle<DiskAdaptor> DiskAdaptorHandle;
|
||||||
|
|
|
@ -36,7 +36,9 @@
|
||||||
#include "MultiDiskAdaptor.h"
|
#include "MultiDiskAdaptor.h"
|
||||||
#include "FileEntry.h"
|
#include "FileEntry.h"
|
||||||
#include "SingleFileAllocationIterator.h"
|
#include "SingleFileAllocationIterator.h"
|
||||||
#include "FallocFileAllocationIterator.h"
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
|
# include "FallocFileAllocationIterator.h"
|
||||||
|
#endif // HAVE_POSIX_FALLOCATE
|
||||||
#include "DiskWriter.h"
|
#include "DiskWriter.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
@ -62,12 +64,15 @@ void MultiFileAllocationIterator::allocateChunk()
|
||||||
_diskAdaptor->openIfNot(entry, &DiskWriterEntry::openFile);
|
_diskAdaptor->openIfNot(entry, &DiskWriterEntry::openFile);
|
||||||
if(entry->needsFileAllocation() && entry->size() < fileEntry->getLength()) {
|
if(entry->needsFileAllocation() && entry->size() < fileEntry->getLength()) {
|
||||||
// Calling private function of MultiDiskAdaptor.
|
// Calling private function of MultiDiskAdaptor.
|
||||||
|
#ifdef HAVE_POSIX_FALLOCATE
|
||||||
if(_diskAdaptor->doesFallocate()) {
|
if(_diskAdaptor->doesFallocate()) {
|
||||||
_fileAllocationIterator.reset
|
_fileAllocationIterator.reset
|
||||||
(new FallocFileAllocationIterator(entry->getDiskWriter().get(),
|
(new FallocFileAllocationIterator(entry->getDiskWriter().get(),
|
||||||
entry->size(),
|
entry->size(),
|
||||||
fileEntry->getLength()));
|
fileEntry->getLength()));
|
||||||
} else {
|
} else
|
||||||
|
#endif // HAVE_POSIX_FALLOCATE
|
||||||
|
{
|
||||||
SharedHandle<SingleFileAllocationIterator> fa
|
SharedHandle<SingleFileAllocationIterator> fa
|
||||||
(new SingleFileAllocationIterator(entry->getDiskWriter().get(),
|
(new SingleFileAllocationIterator(entry->getDiskWriter().get(),
|
||||||
entry->size(),
|
entry->size(),
|
||||||
|
|
Loading…
Reference in New Issue