• Ronnie Sahlberg's avatar
    cifs: improve fallocate emulation · 966a3cb7
    Ronnie Sahlberg authored
    RHBZ: 1866684
    
    We don't have a real fallocate in the SMB2 protocol so we used to emulate fallocate
    by simply switching the file to become non-sparse. But as that could potantially consume
    a lot more data than we intended to fallocate (large sparse file and fallocating a thin
    slice in the middle) we would only do this IFF the fallocate request was for virtually
    the entire file.
    
    This patch improves this and starts allowing us to fallocate smaller chunks of a file by
    overwriting the region with 0, for the parts that are unallocated.
    
    The method used is to first query the server for FSCTL_QUERY_ALLOCATED_RANGES to find what
    is unallocated in the fallocate range and then to only overwrite-with-zero the unallocated
    ranges to fill in the holes.
    
    As overwriting-with-zero is different from just allocating blocks, and potentially much
    more expensive, we limit this to only allow fallocate ranges up to 1Mb in size.
    Reported-by: default avatarkernel test robot <lkp@intel.com>
    Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
    Acked-by: default avatarAurelien Aptel <aaptel@suse.com>
    Acked-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
    Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
    966a3cb7
smb2ops.c 163 KB