• Damien Le Moal's avatar
    zonefs: Fix O_APPEND async write handling · ebfd68cd
    Damien Le Moal authored
    zonefs updates the size of a sequential zone file inode only on
    completion of direct writes. When executing asynchronous append writes
    (with a file open with O_APPEND or using RWF_APPEND), the use of the
    current inode size in generic_write_checks() to set an iocb offset thus
    leads to unaligned write if an application issues an append write
    operation with another write already being executed.
    
    Fix this problem by introducing zonefs_write_checks() as a modified
    version of generic_write_checks() using the file inode wp_offset for an
    append write iocb offset. Also introduce zonefs_write_check_limits() to
    replace generic_write_check_limits() call. This zonefs special helper
    makes sure that the maximum file limit used is the maximum size of the
    file being accessed.
    
    Since zonefs_write_checks() already truncates the iov_iter, the calls
    to iov_iter_truncate() in zonefs_file_dio_write() and
    zonefs_file_buffered_write() are removed.
    
    Fixes: 8dcc1a9d ("fs: New zonefs file system")
    Cc: <stable@vger.kernel.org>
    Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    ebfd68cd
super.c 46.5 KB