forked from premiere/premiere-libtorrent
support O_NOATIME on linux and use it by default
This commit is contained in:
parent
859f412189
commit
1b2798970c
|
@ -177,6 +177,7 @@ namespace libtorrent
|
|||
no_buffer = 4,
|
||||
mode_mask = rw_mask | no_buffer,
|
||||
sparse = 8,
|
||||
no_atime = 16,
|
||||
|
||||
attribute_hidden = 0x1000,
|
||||
attribute_executable = 0x2000,
|
||||
|
|
|
@ -190,6 +190,7 @@ namespace libtorrent
|
|||
, guided_read_cache(true)
|
||||
, default_cache_min_age(1)
|
||||
, num_optimistic_unchoke_slots(0)
|
||||
, no_atime_storage(true)
|
||||
{}
|
||||
|
||||
// this is the user agent that will be sent to the tracker
|
||||
|
@ -709,6 +710,10 @@ namespace libtorrent
|
|||
// the global number of optimistic unchokes
|
||||
// 0 means automatic
|
||||
int num_optimistic_unchoke_slots;
|
||||
|
||||
// if set to true, files won't have their atime updated
|
||||
// on disk reads. This works on linux
|
||||
bool no_atime_storage;
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
|
11
src/file.cpp
11
src/file.cpp
|
@ -769,8 +769,17 @@ namespace libtorrent
|
|||
static const int no_buffer_flag[] = {0, 0};
|
||||
#endif
|
||||
|
||||
#ifdef O_NOATIME
|
||||
static const int no_atime_flag[] = {0, O_NOATIME};
|
||||
#endif
|
||||
|
||||
m_fd = ::open(convert_to_native(path).c_str()
|
||||
, mode_array[mode & rw_mask] | no_buffer_flag[(mode & no_buffer) >> 2], permissions);
|
||||
, mode_array[mode & rw_mask]
|
||||
| no_buffer_flag[(mode & no_buffer) >> 2]
|
||||
#ifdef O_NOATIME
|
||||
| no_atime_flag[(mode & no_atime) >> 4]
|
||||
#endif
|
||||
, permissions);
|
||||
|
||||
#ifdef TORRENT_LINUX
|
||||
// workaround for linux bug
|
||||
|
|
|
@ -1021,6 +1021,7 @@ namespace aux {
|
|||
|| m_settings.allow_reordered_disk_operations != s.allow_reordered_disk_operations
|
||||
|| m_settings.file_pool_size != s.file_pool_size
|
||||
|| m_settings.volatile_read_cache != s.volatile_read_cache
|
||||
|| m_settings.no_atime_storage!= s.no_atime_storage
|
||||
|| m_settings.low_prio_disk != s.low_prio_disk)
|
||||
update_disk_io_thread = true;
|
||||
|
||||
|
|
|
@ -1304,6 +1304,7 @@ ret:
|
|||
&& ((fe.offset + fe.file_base) & (m_page_size-1)) == 0))
|
||||
mode |= file::no_buffer;
|
||||
if (!m_allocate_files) mode |= file::sparse;
|
||||
if (m_settings && settings().no_atime_storage) mode |= file::no_atime;
|
||||
|
||||
return m_pool.open_file(const_cast<storage*>(this), combine_path(m_save_path, fe.path), mode, ec);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue