• Maxim Patlasov's avatar
    fuse: fix alignment in short read optimization for async_dio · e5c5f05d
    Maxim Patlasov authored
    The bug was introduced with async_dio feature: trying to optimize short reads,
    we cut number-of-bytes-to-read to i_size boundary. Hence the following example:
    
    	truncate --size=300 /mnt/file
    	dd if=/mnt/file of=/dev/null iflag=direct
    
    led to FUSE_READ request of 300 bytes size. This turned out to be problem
    for userspace fuse implementations who rely on assumption that kernel fuse
    does not change alignment of request from client FS.
    
    The patch turns off the optimization if async_dio is disabled. And, if it's
    enabled, the patch fixes adjustment of number-of-bytes-to-read to preserve
    alignment.
    
    Note, that we cannot throw out short read optimization entirely because
    otherwise a direct read of a huge size issued on a tiny file would generate
    a huge amount of fuse requests and most of them would be ACKed by userspace
    with zero bytes read.
    Signed-off-by: default avatarMaxim Patlasov <MPatlasov@parallels.com>
    Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
    e5c5f05d
file.c 62.1 KB