• Hugh Dickins's avatar
    tmpfs: trivial support for direct IO · e88e0d36
    Hugh Dickins authored
    
    
    Depending upon your philosophical viewpoint, either tmpfs always does
    direct IO, or it cannot ever do direct IO; but whichever, if tmpfs is to
    stand in for a more sophisticated filesystem, it can be helpful for tmpfs
    to support O_DIRECT.  So, give tmpfs a shmem_file_open() method, to set
    the FMODE_CAN_ODIRECT flag: then unchanged shmem_file_read_iter() and new
    shmem_file_write_iter() do the work (without any shmem_direct_IO() stub).
    
    Perhaps later, once the direct_IO method has been eliminated from all
    filesystems, generic_file_write_iter() will be such that tmpfs can again
    use it, even for O_DIRECT.
    
    xfstests auto generic which were not run on tmpfs before but now pass:
    036 091 113 125 130 133 135 198 207 208 209 210 211 212 214 226 239 263
    323 355 391 406 412 422 427 446 451 465 551 586 591 609 615 647 708 729
    with no new failures.
    
    LTP dio tests which were not run on tmpfs before but now pass:
    dio01 through dio30, except for dio04 and dio10, which fail because
    tmpfs dio read and write allow odd count: tmpfs could be made stricter,
    but would that be an improvement?
    Signed-off-by: default avatarHugh Dickins <hughd@google.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarJan Kara <jack@suse.cz>
    Message-Id: <6f2742-6f1f-cae9-7c5b-ed20fc53215@google.com>
    Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
    e88e0d36
shmem.c 127 KB