Merge pull request #174 from arvidn/fallocate-hack
remove fallocate hack (in master)
This commit is contained in:
commit
50ccce6eed
|
@ -73,7 +73,7 @@
|
||||||
* almost completely changed the storage interface (for custom storage)
|
* almost completely changed the storage interface (for custom storage)
|
||||||
* added support for hashing pieces in multiple threads
|
* added support for hashing pieces in multiple threads
|
||||||
|
|
||||||
|
* fix fallocate hack on linux (fixes corruption on some architectures)
|
||||||
* fix auto-manage bug with announce to tracker/lsd/dht limits
|
* fix auto-manage bug with announce to tracker/lsd/dht limits
|
||||||
* improve DHT routing table to not create an unbalanced tree
|
* improve DHT routing table to not create an unbalanced tree
|
||||||
* fix bug in uTP that would cause any connection taking more than one second
|
* fix bug in uTP that would cause any connection taking more than one second
|
||||||
|
|
|
@ -224,6 +224,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_USE_IFADDRS 1
|
#define TORRENT_USE_IFADDRS 1
|
||||||
#define TORRENT_USE_POSIX_MEMALIGN 1
|
#define TORRENT_USE_POSIX_MEMALIGN 1
|
||||||
#define TORRENT_USE_FDATASYNC 1
|
#define TORRENT_USE_FDATASYNC 1
|
||||||
|
|
||||||
|
// posix_fallocate() is available under this condition
|
||||||
|
#if _XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L
|
||||||
|
#define TORRENT_HAS_FALLOCATE 1
|
||||||
|
#else
|
||||||
|
#define TORRENT_HAS_FALLOCATE 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // ANDROID
|
#endif // ANDROID
|
||||||
|
|
||||||
#if defined __GLIBC__ && ( defined __x86_64__ || defined __i386 \
|
#if defined __GLIBC__ && ( defined __x86_64__ || defined __i386 \
|
||||||
|
|
36
src/file.cpp
36
src/file.cpp
|
@ -131,23 +131,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define lseek lseek64
|
#define lseek lseek64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <asm/unistd.h> // For __NR_fallocate
|
|
||||||
|
|
||||||
// circumvent the lack of support in glibc
|
|
||||||
static int my_fallocate(int fd, int mode, loff_t offset, loff_t len)
|
|
||||||
{
|
|
||||||
#ifdef __NR_fallocate
|
|
||||||
// the man page on fallocate differes between versions of linux.
|
|
||||||
// it appears that fallocate in fact sets errno and returns -1
|
|
||||||
// on failure.
|
|
||||||
return syscall(__NR_fallocate, fd, mode, offset, len);
|
|
||||||
#else
|
|
||||||
// pretend that the system call doesn't exist
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined __APPLE__ && defined __MACH__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
|
#elif defined __APPLE__ && defined __MACH__ && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
|
||||||
// mac specifics
|
// mac specifics
|
||||||
|
|
||||||
|
@ -2136,23 +2119,6 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_LINUX
|
|
||||||
ret = my_fallocate(native_handle(), 0, 0, s);
|
|
||||||
// if we return 0, everything went fine
|
|
||||||
// the fallocate call succeeded
|
|
||||||
if (ret == 0) return true;
|
|
||||||
// otherwise, something went wrong. If the error
|
|
||||||
// is ENOSYS, just keep going and do it the old-fashioned
|
|
||||||
// way. If fallocate failed with some other error, it
|
|
||||||
// probably means the user should know about it, error out
|
|
||||||
// and report it.
|
|
||||||
if (errno != ENOSYS && errno != EOPNOTSUPP && errno != EINVAL)
|
|
||||||
{
|
|
||||||
ec.assign(errno, generic_category());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif // TORRENT_LINUX
|
|
||||||
|
|
||||||
#if TORRENT_HAS_FALLOCATE
|
#if TORRENT_HAS_FALLOCATE
|
||||||
// if fallocate failed, we have to use posix_fallocate
|
// if fallocate failed, we have to use posix_fallocate
|
||||||
// which can be painfully slow
|
// which can be painfully slow
|
||||||
|
@ -2160,7 +2126,7 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER {
|
||||||
// define TORRENT_HAS_FALLOCATE to 0.
|
// define TORRENT_HAS_FALLOCATE to 0.
|
||||||
ret = posix_fallocate(native_handle(), 0, s);
|
ret = posix_fallocate(native_handle(), 0, s);
|
||||||
// posix_allocate fails with EINVAL in case the underlying
|
// posix_allocate fails with EINVAL in case the underlying
|
||||||
// filesystem does bot support this operation
|
// filesystem does not support this operation
|
||||||
if (ret != 0 && ret != EINVAL)
|
if (ret != 0 && ret != EINVAL)
|
||||||
{
|
{
|
||||||
ec.assign(ret, generic_category());
|
ec.assign(ret, generic_category());
|
||||||
|
|
Loading…
Reference in New Issue