• Marko Mäkelä's avatar
    MDEV-17380 innodb_flush_neighbors=ON should be ignored on SSD · 10dd290b
    Marko Mäkelä authored
    For tablespaces that do not reside on spinning storage, it does
    not make sense to attempt to write nearby pages when writing out
    dirty pages from the InnoDB buffer pool. It is actually detrimental
    to performance and to the life span of flash ROM storage.
    
    With this change, MariaDB will detect whether an InnoDB file resides
    on solid-state storage. The detection has been implemented for Linux
    and Microsoft Windows. For other systems, we will err on the safe side
    and assume that files reside on SSD.
    
    As part of this change, we will reduce the number of fstat() calls
    when opening data files on POSIX systems and slightly clean up some
    file I/O code.
    
    FIXME: os_is_sparse_file_supported() on POSIX works in a destructive
    manner. Thus, we can only invoke it when creating files, not when
    opening them.
    
    For diagnostics, we introduce the column ON_SSD to the table
    INFORMATION_SCHEMA.INNODB_TABLESPACES_SCRUBBING. The table
    INNODB_SYS_TABLESPACES might seem more appropriate, but its purpose
    is to reflect the contents of the InnoDB system table SYS_TABLESPACES,
    which we would like to remove at some point.
    
    On Microsoft Windows, querying StorageDeviceSeekPenaltyProperty
    sometimes returns ERROR_GEN_FAILURE instead of ERROR_INVALID_FUNCTION
    or ERROR_NOT_SUPPORTED. We will silently ignore also this error,
    and assume that the file does not reside on SSD.
    
    On Linux, the detection will be based on the files
    /sys/block/*/queue/rotational and /sys/block/*/dev.
    Especially for USB storage, it is possible that
    /sys/block/*/queue/rotational will wrongly report 1 instead of 0.
    
    fil_node_t::on_ssd: Whether the InnoDB data file resides on
    solid-state storage.
    
    fil_system_t::ssd: Collection of Linux block devices that reside on
    non-rotational storage.
    
    fil_system_t::create(): Detect ssd on Linux based on the contents
    of /sys/block/*/queue/rotational and /sys/block/*/dev.
    
    fil_system_t::is_ssd(dev_t): Determine if a Linux block device is
    non-rotational. Partitions will be identified with the containing
    block device by assuming that the least significant 4 bits of the
    minor number identify a partition, and that the "partition number"
    of the entire device is 0.
    10dd290b
fil0fil.h 52.7 KB