forked from premiere/premiere-libtorrent
remove deprecated disk_io_thread operations (#1284)
This commit is contained in:
parent
b61ebca14a
commit
09cbd0a51d
|
@ -67,13 +67,6 @@ namespace libtorrent
|
||||||
, add_torrent_params const* resume_data
|
, add_torrent_params const* resume_data
|
||||||
, std::vector<std::string>& links
|
, std::vector<std::string>& links
|
||||||
, std::function<void(disk_io_job const*)> handler) = 0;
|
, std::function<void(disk_io_job const*)> handler) = 0;
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
virtual void async_cache_piece(piece_manager* storage, int piece
|
|
||||||
, std::function<void(disk_io_job const*)> handler) = 0;
|
|
||||||
virtual void async_finalize_file(piece_manager*, int file
|
|
||||||
, std::function<void(disk_io_job const*)> handler
|
|
||||||
= std::function<void(disk_io_job const*)>()) = 0;
|
|
||||||
#endif
|
|
||||||
virtual void async_flush_piece(piece_manager* storage, int piece
|
virtual void async_flush_piece(piece_manager* storage, int piece
|
||||||
, std::function<void(disk_io_job const*)> handler
|
, std::function<void(disk_io_job const*)> handler
|
||||||
= std::function<void(disk_io_job const*)>()) = 0;
|
= std::function<void(disk_io_job const*)>()) = 0;
|
||||||
|
|
|
@ -86,10 +86,6 @@ namespace libtorrent
|
||||||
, check_fastresume
|
, check_fastresume
|
||||||
, rename_file
|
, rename_file
|
||||||
, stop_torrent
|
, stop_torrent
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
, cache_piece
|
|
||||||
, finalize_file
|
|
||||||
#endif
|
|
||||||
, flush_piece
|
, flush_piece
|
||||||
, flush_hashed
|
, flush_hashed
|
||||||
, flush_storage
|
, flush_storage
|
||||||
|
|
|
@ -311,13 +311,6 @@ namespace libtorrent
|
||||||
, std::function<void(disk_io_job const*)> handler) override;
|
, std::function<void(disk_io_job const*)> handler) override;
|
||||||
void async_stop_torrent(piece_manager* storage
|
void async_stop_torrent(piece_manager* storage
|
||||||
, std::function<void(disk_io_job const*)> handler) override;
|
, std::function<void(disk_io_job const*)> handler) override;
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
void async_cache_piece(piece_manager* storage, int piece
|
|
||||||
, std::function<void(disk_io_job const*)> handler) override;
|
|
||||||
void async_finalize_file(piece_manager* storage, int file
|
|
||||||
, std::function<void(disk_io_job const*)> handler
|
|
||||||
= std::function<void(disk_io_job const*)>()) override;
|
|
||||||
#endif
|
|
||||||
void async_flush_piece(piece_manager* storage, int piece
|
void async_flush_piece(piece_manager* storage, int piece
|
||||||
, std::function<void(disk_io_job const*)> handler
|
, std::function<void(disk_io_job const*)> handler
|
||||||
= std::function<void(disk_io_job const*)>()) override;
|
= std::function<void(disk_io_job const*)>()) override;
|
||||||
|
@ -402,10 +395,6 @@ namespace libtorrent
|
||||||
int do_rename_file(disk_io_job* j, jobqueue_t& completed_jobs);
|
int do_rename_file(disk_io_job* j, jobqueue_t& completed_jobs);
|
||||||
int do_stop_torrent(disk_io_job* j, jobqueue_t& completed_jobs);
|
int do_stop_torrent(disk_io_job* j, jobqueue_t& completed_jobs);
|
||||||
int do_read_and_hash(disk_io_job* j, jobqueue_t& completed_jobs);
|
int do_read_and_hash(disk_io_job* j, jobqueue_t& completed_jobs);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
int do_cache_piece(disk_io_job* j, jobqueue_t& completed_jobs);
|
|
||||||
int do_finalize_file(disk_io_job* j, jobqueue_t& completed_jobs);
|
|
||||||
#endif
|
|
||||||
int do_flush_piece(disk_io_job* j, jobqueue_t& completed_jobs);
|
int do_flush_piece(disk_io_job* j, jobqueue_t& completed_jobs);
|
||||||
int do_flush_hashed(disk_io_job* j, jobqueue_t& completed_jobs);
|
int do_flush_hashed(disk_io_job* j, jobqueue_t& completed_jobs);
|
||||||
int do_flush_storage(disk_io_job* j, jobqueue_t& completed_jobs);
|
int do_flush_storage(disk_io_job* j, jobqueue_t& completed_jobs);
|
||||||
|
|
|
@ -384,7 +384,6 @@ namespace libtorrent
|
||||||
num_fenced_save_resume_data,
|
num_fenced_save_resume_data,
|
||||||
num_fenced_rename_file,
|
num_fenced_rename_file,
|
||||||
num_fenced_stop_torrent,
|
num_fenced_stop_torrent,
|
||||||
num_fenced_cache_piece,
|
|
||||||
num_fenced_flush_piece,
|
num_fenced_flush_piece,
|
||||||
num_fenced_flush_hashed,
|
num_fenced_flush_hashed,
|
||||||
num_fenced_flush_storage,
|
num_fenced_flush_storage,
|
||||||
|
|
|
@ -338,21 +338,6 @@ namespace libtorrent
|
||||||
//
|
//
|
||||||
virtual void delete_files(int options, storage_error& ec) = 0;
|
virtual void delete_files(int options, storage_error& ec) = 0;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
// This function is called each time a file is completely downloaded. The
|
|
||||||
// storage implementation can perform last operations on a file. The file
|
|
||||||
// will not be opened for writing after this.
|
|
||||||
//
|
|
||||||
// ``index`` is the index of the file that completed.
|
|
||||||
//
|
|
||||||
// On windows the default storage implementation clears the sparse file
|
|
||||||
// flag on the specified file.
|
|
||||||
//
|
|
||||||
// If an error occurs, ``storage_error`` should be set to reflect it.
|
|
||||||
//
|
|
||||||
virtual void finalize_file(int, storage_error&) {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// called periodically (useful for deferred flushing). When returning
|
// called periodically (useful for deferred flushing). When returning
|
||||||
// false, it means no more ticks are necessary. Any disk job submitted
|
// false, it means no more ticks are necessary. Any disk job submitted
|
||||||
// will re-enable ticking. The default will always turn ticking back
|
// will re-enable ticking. The default will always turn ticking back
|
||||||
|
@ -393,9 +378,6 @@ namespace libtorrent
|
||||||
// hidden
|
// hidden
|
||||||
~default_storage();
|
~default_storage();
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
void finalize_file(int file, storage_error& ec) override;
|
|
||||||
#endif
|
|
||||||
virtual bool has_any_file(storage_error& ec) override;
|
virtual bool has_any_file(storage_error& ec) override;
|
||||||
virtual void set_file_priority(std::vector<std::uint8_t> const& prio
|
virtual void set_file_priority(std::vector<std::uint8_t> const& prio
|
||||||
, storage_error& ec) override;
|
, storage_error& ec) override;
|
||||||
|
|
|
@ -195,10 +195,6 @@ const char* const job_action_name[] =
|
||||||
"check_fastresume",
|
"check_fastresume",
|
||||||
"rename_file",
|
"rename_file",
|
||||||
"stop_torrent",
|
"stop_torrent",
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
"cache_piece",
|
|
||||||
"finalize_file",
|
|
||||||
#endif
|
|
||||||
"flush_piece",
|
"flush_piece",
|
||||||
"flush_hashed",
|
"flush_hashed",
|
||||||
"flush_storage",
|
"flush_storage",
|
||||||
|
|
|
@ -1023,10 +1023,6 @@ namespace libtorrent
|
||||||
&disk_io_thread::do_check_fastresume,
|
&disk_io_thread::do_check_fastresume,
|
||||||
&disk_io_thread::do_rename_file,
|
&disk_io_thread::do_rename_file,
|
||||||
&disk_io_thread::do_stop_torrent,
|
&disk_io_thread::do_stop_torrent,
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
&disk_io_thread::do_cache_piece,
|
|
||||||
&disk_io_thread::do_finalize_file,
|
|
||||||
#endif
|
|
||||||
&disk_io_thread::do_flush_piece,
|
&disk_io_thread::do_flush_piece,
|
||||||
&disk_io_thread::do_flush_hashed,
|
&disk_io_thread::do_flush_hashed,
|
||||||
&disk_io_thread::do_flush_storage,
|
&disk_io_thread::do_flush_storage,
|
||||||
|
@ -1905,30 +1901,6 @@ namespace libtorrent
|
||||||
add_completed_jobs(completed_jobs);
|
add_completed_jobs(completed_jobs);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
void disk_io_thread::async_cache_piece(piece_manager* storage, int piece
|
|
||||||
, std::function<void(disk_io_job const*)> handler)
|
|
||||||
{
|
|
||||||
disk_io_job* j = allocate_job(disk_io_job::cache_piece);
|
|
||||||
j->storage = storage->shared_from_this();
|
|
||||||
j->piece = piece;
|
|
||||||
j->callback = std::move(handler);
|
|
||||||
|
|
||||||
add_job(j);
|
|
||||||
}
|
|
||||||
|
|
||||||
void disk_io_thread::async_finalize_file(piece_manager* storage, int file
|
|
||||||
, std::function<void(disk_io_job const*)> handler)
|
|
||||||
{
|
|
||||||
disk_io_job* j = allocate_job(disk_io_job::finalize_file);
|
|
||||||
j->storage = storage->shared_from_this();
|
|
||||||
j->piece = file;
|
|
||||||
j->callback = std::move(handler);
|
|
||||||
|
|
||||||
add_job(j);
|
|
||||||
}
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
void disk_io_thread::async_flush_piece(piece_manager* storage, int piece
|
void disk_io_thread::async_flush_piece(piece_manager* storage, int piece
|
||||||
, std::function<void(disk_io_job const*)> handler)
|
, std::function<void(disk_io_job const*)> handler)
|
||||||
{
|
{
|
||||||
|
@ -2528,116 +2500,6 @@ namespace libtorrent
|
||||||
return j->error ? -1 : 0;
|
return j->error ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
int disk_io_thread::do_cache_piece(disk_io_job* j, jobqueue_t& /* completed_jobs */ )
|
|
||||||
{
|
|
||||||
INVARIANT_CHECK;
|
|
||||||
TORRENT_ASSERT(j->buffer.disk_block == nullptr);
|
|
||||||
|
|
||||||
if (m_settings.get_int(settings_pack::cache_size) == 0
|
|
||||||
|| m_settings.get_bool(settings_pack::use_read_cache) == false)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
int const file_flags = file_flags_for_job(j
|
|
||||||
, m_settings.get_bool(settings_pack::coalesce_reads));
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> l(m_cache_mutex);
|
|
||||||
|
|
||||||
cached_piece_entry* pe = m_disk_cache.find_piece(j);
|
|
||||||
if (pe == nullptr)
|
|
||||||
{
|
|
||||||
int cache_state = (j->flags & disk_io_job::volatile_read)
|
|
||||||
? cached_piece_entry::volatile_read_lru
|
|
||||||
: cached_piece_entry::read_lru1;
|
|
||||||
pe = m_disk_cache.allocate_piece(j, cache_state);
|
|
||||||
}
|
|
||||||
if (pe == nullptr)
|
|
||||||
{
|
|
||||||
j->error.ec = error::no_memory;
|
|
||||||
j->error.operation = storage_error::alloc_cache_piece;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
|
||||||
pe->piece_log.push_back(piece_log_t(j->action));
|
|
||||||
#endif
|
|
||||||
TORRENT_PIECE_ASSERT(pe->cache_state <= cached_piece_entry::read_lru1
|
|
||||||
|| pe->cache_state == cached_piece_entry::read_lru2, pe);
|
|
||||||
|
|
||||||
piece_refcount_holder refcount_holder(pe);
|
|
||||||
|
|
||||||
int block_size = m_disk_cache.block_size();
|
|
||||||
int piece_size = j->storage->files()->piece_size(j->piece);
|
|
||||||
int blocks_in_piece = (piece_size + block_size - 1) / block_size;
|
|
||||||
|
|
||||||
file::iovec_t iov;
|
|
||||||
int ret = 0;
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
// TODO: it would be nice to not have to lock the std::mutex every
|
|
||||||
// turn through this loop
|
|
||||||
for (int i = 0; i < blocks_in_piece; ++i)
|
|
||||||
{
|
|
||||||
iov.iov_len = (std::min)(block_size, piece_size - offset);
|
|
||||||
|
|
||||||
// is the block already in the cache?
|
|
||||||
if (pe->blocks[i].buf) continue;
|
|
||||||
l.unlock();
|
|
||||||
|
|
||||||
iov.iov_base = m_disk_cache.allocate_buffer("read cache");
|
|
||||||
|
|
||||||
if (iov.iov_base == nullptr)
|
|
||||||
{
|
|
||||||
refcount_holder.release();
|
|
||||||
m_disk_cache.maybe_free_piece(pe);
|
|
||||||
j->error.ec = errors::no_memory;
|
|
||||||
j->error.operation = storage_error::alloc_cache_piece;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
DLOG("do_cache_piece: reading (piece: %d block: %d)\n"
|
|
||||||
, int(pe->piece), i);
|
|
||||||
|
|
||||||
time_point start_time = clock_type::now();
|
|
||||||
|
|
||||||
ret = j->storage->get_storage_impl()->readv(iov, j->piece
|
|
||||||
, offset, file_flags, j->error);
|
|
||||||
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
l.lock();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!j->error.ec)
|
|
||||||
{
|
|
||||||
std::uint32_t read_time = total_microseconds(clock_type::now() - start_time);
|
|
||||||
m_read_time.add_sample(read_time);
|
|
||||||
|
|
||||||
m_stats_counters.inc_stats_counter(counters::num_blocks_read);
|
|
||||||
m_stats_counters.inc_stats_counter(counters::num_read_ops);
|
|
||||||
m_stats_counters.inc_stats_counter(counters::disk_read_time, read_time);
|
|
||||||
m_stats_counters.inc_stats_counter(counters::disk_job_time, read_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
offset += block_size;
|
|
||||||
|
|
||||||
l.lock();
|
|
||||||
m_disk_cache.insert_blocks(pe, i, iov, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
refcount_holder.release();
|
|
||||||
m_disk_cache.maybe_free_piece(pe);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int disk_io_thread::do_finalize_file(disk_io_job* j, jobqueue_t& /* completed_jobs */)
|
|
||||||
{
|
|
||||||
j->storage->get_storage_impl()->finalize_file(j->piece, j->error);
|
|
||||||
return j->error ? -1 : 0;
|
|
||||||
}
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void get_cache_info_impl(cached_piece_info& info, cached_piece_entry const* i
|
void get_cache_info_impl(cached_piece_info& info, cached_piece_entry const* i
|
||||||
|
|
|
@ -384,7 +384,6 @@ namespace libtorrent
|
||||||
METRIC(disk, num_fenced_save_resume_data)
|
METRIC(disk, num_fenced_save_resume_data)
|
||||||
METRIC(disk, num_fenced_rename_file)
|
METRIC(disk, num_fenced_rename_file)
|
||||||
METRIC(disk, num_fenced_stop_torrent)
|
METRIC(disk, num_fenced_stop_torrent)
|
||||||
METRIC(disk, num_fenced_cache_piece)
|
|
||||||
METRIC(disk, num_fenced_flush_piece)
|
METRIC(disk, num_fenced_flush_piece)
|
||||||
METRIC(disk, num_fenced_flush_hashed)
|
METRIC(disk, num_fenced_flush_hashed)
|
||||||
METRIC(disk, num_fenced_flush_storage)
|
METRIC(disk, num_fenced_flush_storage)
|
||||||
|
|
|
@ -592,10 +592,6 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
void default_storage::finalize_file(int, storage_error&) {}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool default_storage::has_any_file(storage_error& ec)
|
bool default_storage::has_any_file(storage_error& ec)
|
||||||
{
|
{
|
||||||
m_stat_cache.reserve(files().num_files());
|
m_stat_cache.reserve(files().num_files());
|
||||||
|
|
|
@ -71,9 +71,6 @@ struct test_storage_impl : storage_interface
|
||||||
void rename_file(int index, std::string const& new_filename
|
void rename_file(int index, std::string const& new_filename
|
||||||
, storage_error& ec) override {}
|
, storage_error& ec) override {}
|
||||||
void delete_files(int, storage_error& ec) override {}
|
void delete_files(int, storage_error& ec) override {}
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
void finalize_file(int, storage_error&) override {}
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void nop() {}
|
static void nop() {}
|
||||||
|
|
|
@ -14,7 +14,7 @@ if len(sys.argv) < 2:
|
||||||
keys = ['write', 'read', 'read-cache-hit', 'hash', 'move', 'release', 'idle', \
|
keys = ['write', 'read', 'read-cache-hit', 'hash', 'move', 'release', 'idle', \
|
||||||
'delete', 'check_fastresume', 'check_files', 'clear-cache', \
|
'delete', 'check_fastresume', 'check_files', 'clear-cache', \
|
||||||
'abort_thread', 'abort_torrent', 'save_resume_data', 'rename_file', \
|
'abort_thread', 'abort_torrent', 'save_resume_data', 'rename_file', \
|
||||||
'flushing', 'update_settings', 'finalize_file', 'sorting_job', \
|
'flushing', 'update_settings', 'sorting_job', \
|
||||||
'check_cache_hit']
|
'check_cache_hit']
|
||||||
throughput_keys = ['write', 'read', 'read-cache-hit']
|
throughput_keys = ['write', 'read', 'read-cache-hit']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue