]> www.infradead.org Git - users/jedix/linux-maple.git/commit
cifs: improve fallocate emulation
authorRonnie Sahlberg <lsahlber@redhat.com>
Thu, 8 Apr 2021 22:40:54 +0000 (08:40 +1000)
committerSteve French <stfrench@microsoft.com>
Tue, 13 Apr 2021 05:03:51 +0000 (00:03 -0500)
commit6e517634784dfc255939c24dd5f3c489eede0d99
tree3a224d9be41bf481e06d9870de723559b1d31650
parent25a626f7ecf6b6a282bd45d03d7a990a31fbe273
cifs: improve fallocate emulation

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 teh 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: kernel test robot <lkp@intel.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/smb2ops.c