• Marko Mäkelä's avatar
    MDEV-33379 innodb_log_file_buffering=OFF causes corruption on bcachefs · 7f7329f0
    Marko Mäkelä authored
    Apparently, invoking fcntl(fd, F_SETFL, O_DIRECT) will lead to
    unexpected behaviour on Linux bcachefs and possibly other file systems,
    depending on the operating system version. So, let us avoid doing that,
    and instead just attempt to pass the O_DIRECT flag to open(). This should
    make us compatible with NetBSD, IBM AIX, as well as Solaris and its
    derivatives.
    
    This fix does not change the fact that we had only implemented
    innodb_log_file_buffering=OFF on systems where we can determine the
    physical block size (typically 512 or 4096 bytes).
    Currently, those operating systems are Linux and Microsoft Windows.
    
    HAVE_FCNTL_DIRECT, os_file_set_nocache(): Remove.
    
    OS_FILE_OVERWRITE, OS_FILE_CREATE_PATH: Remove (never used parameters).
    
    os_file_log_buffered(), os_file_log_maybe_unbuffered(): Helper functions.
    
    os_file_create_simple_func(): When applicable, initially attempt to
    open files in O_DIRECT mode.
    
    os_file_create_func(): When applicable, initially attempt to
    open files in O_DIRECT mode.
    For type==OS_LOG_FILE && create_mode != OS_FILE_CREATE
    we will first invoke stat(2) on the file name to find out if the size
    is compatible with O_DIRECT. If create_mode == OS_FILE_CREATE, we will
    invoke fstat(2) on the created log file afterwards, and may close and
    reopen the file in O_DIRECT mode if applicable.
    
    create_temp_file(): Support O_DIRECT. This is only used if O_TMPFILE is
    available and innodb_disable_sort_file_cache=ON (non-default value).
    Notably, that setting never worked on Microsoft Windows.
    
    row_merge_file_create_mode(): Split from row_merge_file_create_low().
    Create a temporary file in the specified mode.
    
    Reviewed by: Vladislav Vaintroub
    7f7329f0
SunOS.cmake 3.16 KB