improve handling of filesystems not supporting fallocate()

This commit is contained in:
Arvid Norberg 2018-08-19 21:55:31 +02:00 committed by Arvid Norberg
parent c9043dec53
commit 6e80f1f615
4 changed files with 9 additions and 8 deletions

View File

@ -1,3 +1,4 @@
* improve handling of filesystems not supporting fallocate()
* force-proxy no longer disables DHT
* improve connect-boost feature, to make new torrents quickly connect peers

View File

@ -1184,7 +1184,7 @@ namespace libtorrent
int ret = j->storage->get_storage_impl()->readv(&b, 1
, j->piece, j->d.io.offset, file_flags, j->error);
TORRENT_ASSERT(ret >= 0 || j->error.ec);
TORRENT_ASSERT(ret >= 0 || (j->error.ec && j->error.operation != 0));
if (!j->error.ec)
{
@ -1258,6 +1258,8 @@ namespace libtorrent
ret = j->storage->get_storage_impl()->readv(iov, iov_len
, j->piece, adjusted_offset, file_flags, j->error);
TORRENT_ASSERT(ret >= 0 || (j->error.ec && j->error.operation != 0));
if (!j->error.ec)
{
boost::uint32_t const read_time = total_microseconds(clock_type::now() - start_time);
@ -1418,6 +1420,8 @@ namespace libtorrent
int ret = j->storage->get_storage_impl()->writev(&b, 1
, j->piece, j->d.io.offset, file_flags, j->error);
TORRENT_ASSERT(ret >= 0 || (j->error.ec && j->error.operation != 0));
m_stats_counters.inc_stats_counter(counters::num_writing_threads, -1);
if (!j->error.ec)

View File

@ -2154,9 +2154,9 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
// if you get a compile error here, you might want to
// define TORRENT_HAS_FALLOCATE to 0.
ret = posix_fallocate(native_handle(), 0, s);
// posix_allocate fails with EINVAL in case the underlying
// posix_allocate fails with EINVAL or ENOTSUP in case the underlying
// filesystem does not support this operation
if (ret != 0 && ret != EINVAL)
if (ret != 0 && ret != EINVAL && ret != ENOTSUP)
{
ec.assign(ret, system_category());
return false;

View File

@ -457,8 +457,6 @@ namespace libtorrent
file_handle f = open_file(i, file::read_write, ec);
if (ec)
{
ec.file = i;
ec.operation = storage_error::open;
prio = m_file_priority;
return;
}
@ -489,8 +487,6 @@ namespace libtorrent
{
if (ec)
{
ec.file = i;
ec.operation = storage_error::open;
prio = m_file_priority;
return;
}
@ -1600,7 +1596,7 @@ namespace libtorrent
{
ec.ec = e;
ec.file = file;
ec.operation = storage_error::fallocate;
ec.operation = storage_error::stat;
return h;
}