• Dave Chinner's avatar
    xfs: using generic_file_direct_write() is unnecessary · 0cefb29e
    Dave Chinner authored
    generic_file_direct_write() does all sorts of things to make DIO
    work "sorta ok" with mixed buffered IO workloads. We already do
    most of this work in xfs_file_aio_dio_write() because of the locking
    requirements, so there's only a couple of things it does for us.
    
    The first thing is that it does a page cache invalidation after the
    ->direct_IO callout. This can easily be added to the XFS code.
    
    The second thing it does is that if data was written, it updates the
    iov_iter structure to reflect the data written, and then does EOF
    size updates if necessary. For XFS, these EOF size updates are now
    not necessary, as we do them safely and race-free in IO completion
    context. That leaves just the iov_iter update, and that's also moved
    to the XFS code.
    
    Therefore we don't need to call generic_file_direct_write() and in
    doing so remove redundant buffered writeback and page cache
    invalidation calls from the DIO submission path. We also remove a
    racy EOF size update, and make the DIO submission code in XFS much
    easier to follow. Wins all round, really.
    Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
    Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    0cefb29e
xfs_file.c 37.3 KB