Commit daaa881c authored by Sergey Vojtovich's avatar Sergey Vojtovich

libpmem cmake macros

Also added support for MAP_SYNC. It allows to achieve decent performance
with DAX devices even when libpmem is unavailable.

Fixed Windows version of my_msync(): according to manual FlushViewOfFile()
may return before flush is actually completed. It is advised to issue
FlushFileBuffers() after FlushViewOfFile().
parent 42e825dd
......@@ -168,6 +168,7 @@ INCLUDE(mysql_add_executable)
INCLUDE(symlinks)
INCLUDE(compile_flags)
INCLUDE(crc32)
INCLUDE(pmem)
# Handle options
OPTION(DISABLE_SHARED
......
INCLUDE(CheckIncludeFiles)
OPTION(WITH_PMEM "Enable persistent memory features" OFF)
IF(WITH_PMEM)
FIND_LIBRARY(LIBPMEM pmem)
CHECK_INCLUDE_FILES(libpmem.h HAVE_LIBPMEM_H)
IF (NOT LIBPMEM)
MESSAGE(FATAL_ERROR "Can't find libpmem")
ELSEIF(NOT HAVE_LIBPMEM_H)
MESSAGE(FATAL_ERROR "Can't find libpmem.h")
ELSE()
ADD_DEFINITIONS(-DHAVE_PMEM)
ENDIF()
ENDIF()
......@@ -964,6 +964,13 @@ extern ulonglong my_getcputime(void);
#define available_stack_size(CUR,END) (long) ((char*)(END) - (char*)(CUR))
#endif
#ifndef MAP_SYNC
#define MAP_SYNC 0x80000
#endif
#ifndef MAP_SHARED_VALIDATE
#define MAP_SHARED_VALIDATE 0x03
#endif
#ifdef HAVE_SYS_MMAN_H
#ifndef MAP_NOSYNC
#define MAP_NOSYNC 0
......
......@@ -29,6 +29,10 @@ int my_msync(int fd, void *addr, size_t len, int flags)
#elif defined(_WIN32)
#ifndef FILE_DAX_VOLUME
#define FILE_DAX_VOLUME 0x20000000
#endif
static SECURITY_ATTRIBUTES mmap_security_attributes=
{sizeof(SECURITY_ATTRIBUTES), 0, TRUE};
......@@ -61,6 +65,18 @@ void *my_mmap(void *addr, size_t len, int prot,
*/
CloseHandle(hFileMap);
if (flags & MAP_SYNC)
{
DWORD filesystemFlags;
if (!GetVolumeInformationByHandleW(hFile, NULL, 0, NULL, NULL,
&filesystemFlags, NULL, 0) ||
!(filesystemFlags & FILE_DAX_VOLUME))
{
UnmapViewOfFile(ptr);
ptr= NULL;
}
}
if (ptr)
{
DBUG_PRINT("mysys", ("mapped addr: %p", ptr));
......@@ -79,7 +95,8 @@ int my_munmap(void *addr, size_t len)
int my_msync(int fd, void *addr, size_t len, int flags)
{
return FlushViewOfFile(addr, len) ? 0 : -1;
return FlushViewOfFile(addr, len) &&
FlushFileBuffers(my_get_osfhandle(fd)) ? 0 : -1;
}
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment