2009-03-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added 'falloc' parameter for --file-allocation option.  'falloc'
	allocation mode uses posix_fallocate() system call to allocate
	file on disk.  If you are using newer file systems such as ext4
        (with extents support), btrfs or xfs, 'falloc' is your best
	choice. It allocates large(few GiB) files almost instantly.
	Don't use 'falloc' with legacy file systems such as ext3 because
	it takes almost same time as 'prealloc' and it blocks aria2
	entirely until allocation finishes. 'falloc' may not be
	available if your system doesn't have posix_fallocate() system
	call.
	* configure.ac
	* src/AbstractDiskWriter.cc
	* src/AbstractDiskWriter.h
	* src/AbstractSingleDiskAdaptor.cc
	* src/BinaryStream.h
	* src/BtCheckIntegrityEntry.cc
	* src/ByteArrayDiskWriter.h
	* src/CheckIntegrityEntry.cc
	* src/CheckIntegrityEntry.h
	* src/DefaultPieceStorage.cc
	* src/DiskAdaptor.cc
	* src/DiskAdaptor.h
	* src/DiskWriter.h
	* src/FallocFileAllocationIterator.cc
	* src/FallocFileAllocationIterator.h
	* src/FileAllocationEntry.cc
	* src/FileAllocationEntry.h
	* src/Makefile.am
	* src/MultiFileAllocationIterator.cc
	* src/MultiFileAllocationIterator.h
	* src/OptionHandlerFactory.cc
	* src/RequestGroup.cc
	* src/StreamCheckIntegrityEntry.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
	* test/FallocFileAllocationIteratorTest.cc
	* test/Makefile.am
This commit is contained in:
Tatsuhiro Tsujikawa
2009-03-25 05:43:07 +00:00
parent fe614395d6
commit 29c5ef9215
33 changed files with 563 additions and 115 deletions

View File

@@ -0,0 +1,69 @@
/* <!-- copyright */
/*
* aria2 - The high speed download utility
*
* Copyright (C) 2009 Tatsuhiro Tsujikawa
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*/
/* copyright --> */
#include "FallocFileAllocationIterator.h"
#include "DlAbortEx.h"
namespace aria2 {
FallocFileAllocationIterator::FallocFileAllocationIterator
(BinaryStream* stream, off_t offset, uint64_t totalLength):
_stream(stream), _offset(offset), _totalLength(totalLength) {}
void FallocFileAllocationIterator::allocateChunk()
{
if(static_cast<uint64_t>(_offset) > _totalLength) {
throw DlAbortEx("FallocFileAllocationIterator: offset is larger than"
" totalLength");
}
_stream->allocate(_offset, _totalLength-_offset);
_offset = _totalLength;
}
bool FallocFileAllocationIterator::finished()
{
return static_cast<uint64_t>(_offset) == _totalLength;
}
off_t FallocFileAllocationIterator::getCurrentLength()
{
return _offset;
}
uint64_t FallocFileAllocationIterator::getTotalLength()
{
return _totalLength;
}
} // namespace aria2