mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-04 18:04:13 +08:00
mdbx: provide MDBX_USE_SENDFILE and MDBX_USE_SENDFILE options.
Change-Id: Icd9a6487ae6e398276a9e720926ff24de5897c1a
This commit is contained in:
parent
6db7b13266
commit
25e3968199
14
src/core.c
14
src/core.c
@ -16314,10 +16314,8 @@ static int __cold mdbx_env_copy_asis(MDBX_env *env, MDBX_txn *read_txn,
|
|||||||
uint8_t *const data_buffer =
|
uint8_t *const data_buffer =
|
||||||
buffer + ceil_powerof2(meta_bytes, env->me_os_psize);
|
buffer + ceil_powerof2(meta_bytes, env->me_os_psize);
|
||||||
for (size_t offset = meta_bytes; rc == MDBX_SUCCESS && offset < used_size;) {
|
for (size_t offset = meta_bytes; rc == MDBX_SUCCESS && offset < used_size;) {
|
||||||
|
#if MDBX_USE_SENDFILE
|
||||||
if (dest_is_pipe) {
|
if (dest_is_pipe) {
|
||||||
#if (defined(__linux__) || defined(__gnu_linux__)) && \
|
|
||||||
(!defined(__ANDROID_API__) || __ANDROID_API__ >= 21) && \
|
|
||||||
!defined(MDBX_SAFE4QEMU)
|
|
||||||
off_t in_offset = offset;
|
off_t in_offset = offset;
|
||||||
const intptr_t written =
|
const intptr_t written =
|
||||||
sendfile(fd, env->me_lazy_fd, &in_offset, used_size - offset);
|
sendfile(fd, env->me_lazy_fd, &in_offset, used_size - offset);
|
||||||
@ -16327,9 +16325,11 @@ static int __cold mdbx_env_copy_asis(MDBX_env *env, MDBX_txn *read_txn,
|
|||||||
}
|
}
|
||||||
offset = in_offset;
|
offset = in_offset;
|
||||||
continue;
|
continue;
|
||||||
#endif
|
}
|
||||||
} else {
|
#endif /* MDBX_USE_SENDFILE */
|
||||||
#if __GLIBC_PREREQ(2, 27) && defined(_GNU_SOURCE) && !defined(MDBX_SAFE4QEMU)
|
|
||||||
|
#if MDBX_USE_COPYFILERANGE
|
||||||
|
if (!dest_is_pipe) {
|
||||||
off_t in_offset = offset, out_offset = offset;
|
off_t in_offset = offset, out_offset = offset;
|
||||||
ssize_t bytes_copied = copy_file_range(
|
ssize_t bytes_copied = copy_file_range(
|
||||||
env->me_lazy_fd, &in_offset, fd, &out_offset, used_size - offset, 0);
|
env->me_lazy_fd, &in_offset, fd, &out_offset, used_size - offset, 0);
|
||||||
@ -16339,8 +16339,8 @@ static int __cold mdbx_env_copy_asis(MDBX_env *env, MDBX_txn *read_txn,
|
|||||||
}
|
}
|
||||||
offset = in_offset;
|
offset = in_offset;
|
||||||
continue;
|
continue;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif /* MDBX_USE_COPYFILERANGE */
|
||||||
|
|
||||||
/* fallback to portable */
|
/* fallback to portable */
|
||||||
const size_t chunk =
|
const size_t chunk =
|
||||||
|
@ -162,6 +162,26 @@
|
|||||||
#define MDBX_USE_OFDLOCKS_CONFIG STRINGIFY(MDBX_USE_OFDLOCKS)
|
#define MDBX_USE_OFDLOCKS_CONFIG STRINGIFY(MDBX_USE_OFDLOCKS)
|
||||||
#endif /* MDBX_USE_OFDLOCKS */
|
#endif /* MDBX_USE_OFDLOCKS */
|
||||||
|
|
||||||
|
/** Advanced: Using sendfile() syscall (autodetection by default). */
|
||||||
|
#ifndef MDBX_USE_SENDFILE
|
||||||
|
#if (defined(__linux__) || defined(__gnu_linux__)) && \
|
||||||
|
(!defined(__ANDROID_API__) || __ANDROID_API__ >= 21) && \
|
||||||
|
!defined(MDBX_SAFE4QEMU)
|
||||||
|
#define MDBX_USE_SENDFILE 1
|
||||||
|
#else
|
||||||
|
#define MDBX_USE_SENDFILE 0
|
||||||
|
#endif
|
||||||
|
#endif /* MDBX_USE_SENDFILE */
|
||||||
|
|
||||||
|
/** Advanced: Using copy_file_range() syscall (autodetection by default). */
|
||||||
|
#ifndef MDBX_USE_COPYFILERANGE
|
||||||
|
#if __GLIBC_PREREQ(2, 27) && defined(_GNU_SOURCE) && !defined(MDBX_SAFE4QEMU)
|
||||||
|
#define MDBX_USE_COPYFILERANGE 1
|
||||||
|
#else
|
||||||
|
#define MDBX_USE_COPYFILERANGE 0
|
||||||
|
#endif
|
||||||
|
#endif /* MDBX_USE_COPYFILERANGE */
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef MDBX_CPU_WRITEBACK_INCOHERENT
|
#ifndef MDBX_CPU_WRITEBACK_INCOHERENT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user