NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
cosmos1
Oct 25, 2012Aspirant
Anyone interested in compiling rtorrent for Duo V2?
Hello all, I've been using rtorrent with specific setting on my previous NAS box, a meagre Maxtor Shared Storage II with great results. After obtaining my Readynas duo v2 box and being informed tha...
cosmos1
Feb 18, 2013Aspirant
Been some time since our last chat. I don't know if you are still interested (I am for certain) to throw a couple of tests. I am especially interested on whether certain symbols get defined or not. You see, the login for preallocation is in libtorrent in file src/data/socket_file.cc. Can you tell which of the following symbols get defined after running configure?
* HAVE_FALLOCATE
* USE_POSIX_FALLOCATE
I am interested in those two, because they define which method is used when the user selects preallocation. In that scenario, creation of a file happens through Socketfile::set_size (if I understand correctly). In the following, I've pasted this function, removing the SYS_DARWIN check:
I am asking which of HAVE_FALLOCATE and USE_POSIX_FALLOCATE get used here, because I'd like to short circuit perhaps one or the other or both, in order for the preallocation to work properly... If HAVE_FALLOCATE is defined, then according to the piece of code above, preallocation always happens through a call to fallocate. Otherwise, if HAVE_FALLOCATE is not defined but USE_POSIX_FALLOCATE is, then preallocation happens through posix_fallocate... If neither exists, then allocation happens through the following catchall piece of code:
* HAVE_FALLOCATE
* USE_POSIX_FALLOCATE
I am interested in those two, because they define which method is used when the user selects preallocation. In that scenario, creation of a file happens through Socketfile::set_size (if I understand correctly). In the following, I've pasted this function, removing the SYS_DARWIN check:
bool
SocketFile::set_size(uint64_t size, int flags) const {
if (!is_open())
throw internal_error("SocketFile::set_size() called on a closed file");
#ifdef HAVE_FALLOCATE
if (flags & flag_fallocate && fallocate(m_fd, 0, 0, size) == 0)
return true;
#endif
#ifdef USE_POSIX_FALLOCATE
if (flags & flag_fallocate &&
flags & flag_fallocate_blocking &&
posix_fallocate(m_fd, 0, size) == 0)
return true;
#endif
#ifdef SYS_DARWIN
[...] We are not interested here, does not get executed
#endif
if (ftruncate(m_fd, size) == 0)
return true;
// Use workaround to resize files on vfat. It causes the whole
// client to block while it is resizing the files, this really
// should be in a seperate thread.
if (size != 0 &&
lseek(m_fd, size - 1, SEEK_SET) == (off_t)(size - 1) &&
write(m_fd, &size, 1) == 1)
return true;
return false;
}
I am asking which of HAVE_FALLOCATE and USE_POSIX_FALLOCATE get used here, because I'd like to short circuit perhaps one or the other or both, in order for the preallocation to work properly... If HAVE_FALLOCATE is defined, then according to the piece of code above, preallocation always happens through a call to fallocate. Otherwise, if HAVE_FALLOCATE is not defined but USE_POSIX_FALLOCATE is, then preallocation happens through posix_fallocate... If neither exists, then allocation happens through the following catchall piece of code:
if (ftruncate(m_fd, size) == 0)
return true;
// Use workaround to resize files on vfat. It causes the whole
// client to block while it is resizing the files, this really
// should be in a seperate thread.
if (size != 0 &&
lseek(m_fd, size - 1, SEEK_SET) == (off_t)(size - 1) &&
write(m_fd, &size, 1) == 1)
return true;
return false;
Related Content
NETGEAR Academy
Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!