deprecate mmap_cache (#1269)

deprecated mmap_cache feature
This commit is contained in:
Arvid Norberg 2016-10-29 13:42:42 -04:00 committed by GitHub
parent 336030c73b
commit d1a59879cb
9 changed files with 29 additions and 18 deletions

View File

@ -1,3 +1,4 @@
* deprecated mmap_cache feature
* add utility function for generating peer ID fingerprint * add utility function for generating peer ID fingerprint
* fix bug in last-seen-complete * fix bug in last-seen-complete
* remove file size limit in torrent_info filename constructor * remove file size limit in torrent_info filename constructor

View File

@ -1301,7 +1301,6 @@ int main(int argc, char* argv[])
" -C <limit> sets the max cache size. Specified in 16kB blocks\n" " -C <limit> sets the max cache size. Specified in 16kB blocks\n"
" -j disable disk read-ahead\n" " -j disable disk read-ahead\n"
" -z disable piece hash checks (used for benchmarking)\n" " -z disable piece hash checks (used for benchmarking)\n"
" -Z <file> mmap the disk cache to the specified file, should be an SSD\n"
" -0 disable disk I/O, read garbage and don't flush to disk\n" " -0 disable disk I/O, read garbage and don't flush to disk\n"
"\n\n" "\n\n"
"TORRENT is a path to a .torrent file\n" "TORRENT is a path to a .torrent file\n"
@ -1537,10 +1536,6 @@ int main(int argc, char* argv[])
break; break;
} }
case 'X': settings.set_bool(settings_pack::enable_lsd, false); --i; break; case 'X': settings.set_bool(settings_pack::enable_lsd, false); --i; break;
case 'Z':
settings.set_str(settings_pack::mmap_cache, arg);
settings.set_bool(settings_pack::contiguous_recv_buffer, false);
break;
case 'v': settings.set_int(settings_pack::active_downloads, atoi(arg)); case 'v': settings.set_int(settings_pack::active_downloads, atoi(arg));
settings.set_int(settings_pack::active_limit, atoi(arg) * 2); settings.set_int(settings_pack::active_limit, atoi(arg) * 2);
break; break;

View File

@ -1878,7 +1878,8 @@ namespace libtorrent
std::vector<torrent_status> status; std::vector<torrent_status> status;
}; };
struct TORRENT_EXPORT mmap_cache_alert TORRENT_FINAL : alert #ifndef TORRENT_NO_DEPRECATE
struct TORRENT_DEPRECATED TORRENT_EXPORT mmap_cache_alert TORRENT_FINAL : alert
{ {
mmap_cache_alert(aux::stack_allocator& alloc mmap_cache_alert(aux::stack_allocator& alloc
, error_code const& ec); , error_code const& ec);
@ -1889,6 +1890,7 @@ namespace libtorrent
error_code error; error_code error;
}; };
#endif
// The session_stats_alert is posted when the user requests session statistics by // The session_stats_alert is posted when the user requests session statistics by
// calling post_session_stats() on the session object. Its category is // calling post_session_stats() on the session object. Its category is

View File

@ -143,7 +143,7 @@ namespace libtorrent
int m_cache_buffer_chunk_size; int m_cache_buffer_chunk_size;
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
// the file descriptor of the cache mmap file // the file descriptor of the cache mmap file
int m_cache_fd; int m_cache_fd;
// the pointer to the block of virtual address space // the pointer to the block of virtual address space

View File

@ -120,6 +120,7 @@ namespace libtorrent
// omitted. // omitted.
announce_ip, announce_ip,
#ifndef TORRENT_NO_DEPRECATE
// ``mmap_cache`` may be set to a filename where the disk cache will // ``mmap_cache`` may be set to a filename where the disk cache will
// be mmapped to. This could be useful, for instance, to map the disk // be mmapped to. This could be useful, for instance, to map the disk
// cache from regular rotating hard drives onto an SSD drive. Doing // cache from regular rotating hard drives onto an SSD drive. Doing
@ -144,6 +145,9 @@ namespace libtorrent
// This feature requires the ``mmap`` system call, on systems that // This feature requires the ``mmap`` system call, on systems that
// don't have ``mmap`` this setting is ignored. // don't have ``mmap`` this setting is ignored.
mmap_cache, mmap_cache,
#else
deprecated12,
#endif
// this is the client name and version identifier sent to peers in the // this is the client name and version identifier sent to peers in the
// handshake message. If this is an empty string, the user_agent is // handshake message. If this is an empty string, the user_agent is

View File

@ -1349,6 +1349,7 @@ namespace libtorrent {
return msg; return msg;
} }
#ifndef TORRENT_NO_DEPRECATE
mmap_cache_alert::mmap_cache_alert(aux::stack_allocator& mmap_cache_alert::mmap_cache_alert(aux::stack_allocator&
, error_code const& ec): error(ec) , error_code const& ec): error(ec)
{} {}
@ -1360,6 +1361,7 @@ namespace libtorrent {
, convert_from_native(error.message()).c_str()); , convert_from_native(error.message()).c_str());
return msg; return msg;
} }
#endif
peer_error_alert::peer_error_alert(aux::stack_allocator& alloc, torrent_handle const& h peer_error_alert::peer_error_alert(aux::stack_allocator& alloc, torrent_handle const& h
, tcp::endpoint const& ep, peer_id const& peer_id, int op , tcp::endpoint const& ep, peer_id const& peer_id, int op

View File

@ -93,7 +93,7 @@ namespace libtorrent
, m_exceeded_max_size(false) , m_exceeded_max_size(false)
, m_ios(ios) , m_ios(ios)
, m_cache_buffer_chunk_size(0) , m_cache_buffer_chunk_size(0)
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
, m_cache_fd(-1) , m_cache_fd(-1)
, m_cache_pool(0) , m_cache_pool(0)
#endif #endif
@ -116,7 +116,7 @@ namespace libtorrent
m_magic = 0; m_magic = 0;
#endif #endif
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
if (m_cache_pool) if (m_cache_pool)
{ {
munmap(m_cache_pool, boost::uint64_t(m_max_use) * 0x4000); munmap(m_cache_pool, boost::uint64_t(m_max_use) * 0x4000);
@ -175,7 +175,7 @@ namespace libtorrent
TORRENT_ASSERT(l.locked()); TORRENT_ASSERT(l.locked());
TORRENT_UNUSED(l); TORRENT_UNUSED(l);
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
if (m_cache_pool) if (m_cache_pool)
{ {
return buffer >= m_cache_pool && buffer < m_cache_pool return buffer >= m_cache_pool && buffer < m_cache_pool
@ -270,7 +270,7 @@ namespace libtorrent
TORRENT_UNUSED(l); TORRENT_UNUSED(l);
char* ret; char* ret;
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
if (m_cache_pool) if (m_cache_pool)
{ {
if (m_free_list.size() <= (m_max_use - m_low_watermark) if (m_free_list.size() <= (m_max_use - m_low_watermark)
@ -377,7 +377,7 @@ namespace libtorrent
m_using_pool_allocator = m_want_pool_allocator; m_using_pool_allocator = m_want_pool_allocator;
#endif #endif
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
// if we've already allocated an mmap, we can't change // if we've already allocated an mmap, we can't change
// anything unless there are no allocations in use // anything unless there are no allocations in use
if (m_cache_pool && m_in_use > 0) return; if (m_cache_pool && m_in_use > 0) return;
@ -386,10 +386,13 @@ namespace libtorrent
// only allow changing size if we're not using mmapped // only allow changing size if we're not using mmapped
// cache, or if we're just about to turn it off // cache, or if we're just about to turn it off
if ( if (
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
m_cache_pool == 0 || m_cache_pool == 0 ||
sett.get_str(settings_pack::mmap_cache).empty()
#else
true
#endif #endif
sett.get_str(settings_pack::mmap_cache).empty()) )
{ {
int const cache_size = sett.get_int(settings_pack::cache_size); int const cache_size = sett.get_int(settings_pack::cache_size);
if (cache_size < 0) if (cache_size < 0)
@ -452,7 +455,7 @@ namespace libtorrent
m_settings_set = true; m_settings_set = true;
#endif #endif
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
// #error support resizing the map // #error support resizing the map
if (m_cache_pool && sett.get_str(settings_pack::mmap_cache).empty()) if (m_cache_pool && sett.get_str(settings_pack::mmap_cache).empty())
{ {
@ -509,7 +512,7 @@ namespace libtorrent
} }
} }
} }
#endif #endif // TORRENT_HAVE_MMAP
} }
void disk_buffer_pool::free_buffer_impl(char* buf, mutex::scoped_lock& l) void disk_buffer_pool::free_buffer_impl(char* buf, mutex::scoped_lock& l)
@ -521,7 +524,7 @@ namespace libtorrent
TORRENT_ASSERT(l.locked()); TORRENT_ASSERT(l.locked());
TORRENT_UNUSED(l); TORRENT_UNUSED(l);
#if TORRENT_HAVE_MMAP #if TORRENT_HAVE_MMAP && !defined TORRENT_NO_DEPRECATE
if (m_cache_pool) if (m_cache_pool)
{ {
TORRENT_ASSERT(buf >= m_cache_pool); TORRENT_ASSERT(buf >= m_cache_pool);

View File

@ -282,10 +282,14 @@ namespace libtorrent
apply_pack(pack, m_settings); apply_pack(pack, m_settings);
error_code ec; error_code ec;
m_disk_cache.set_settings(m_settings, ec); m_disk_cache.set_settings(m_settings, ec);
#ifndef TORRENT_NO_DEPRECATE
if (ec && alerts.should_post<mmap_cache_alert>()) if (ec && alerts.should_post<mmap_cache_alert>())
{ {
alerts.emplace_alert<mmap_cache_alert>(ec); alerts.emplace_alert<mmap_cache_alert>(ec);
} }
#else
TORRENT_UNUSED(alerts);
#endif
} }
// flush all blocks that are below p->hash.offset, since we've // flush all blocks that are below p->hash.offset, since we've

View File

@ -102,9 +102,9 @@ TORRENT_TEST(test_name)
TEST_NAME(seeding_piece_quota); TEST_NAME(seeding_piece_quota);
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
TEST_NAME(half_open_limit); TEST_NAME(half_open_limit);
TEST_NAME(mmap_cache);
#endif #endif
TEST_NAME(peer_turnover_interval); TEST_NAME(peer_turnover_interval);
TEST_NAME(mmap_cache);
} }
TORRENT_TEST(clear) TORRENT_TEST(clear)