OSDN Git Service

cifs: fix allocation size on newly created files
authorSteve French <stfrench@microsoft.com>
Fri, 19 Mar 2021 05:05:48 +0000 (00:05 -0500)
committerSteve French <stfrench@microsoft.com>
Fri, 19 Mar 2021 16:51:31 +0000 (11:51 -0500)
commit65af8f0166f4d15e61c63db498ec7981acdd897f
tree529634cc41ad29c4136a7f31a43722341919eb90
parentaf3ef3b1031634724a3763606695ebcd113d782b
cifs: fix allocation size on newly created files

Applications that create and extend and write to a file do not
expect to see 0 allocation size.  When file is extended,
set its allocation size to a plausible value until we have a
chance to query the server for it.  When the file is cached
this will prevent showing an impossible number of allocated
blocks (like 0).  This fixes e.g. xfstests 614 which does

    1) create a file and set its size to 64K
    2) mmap write 64K to the file
    3) stat -c %b for the file (to query the number of allocated blocks)

It was failing because we returned 0 blocks.  Even though we would
return the correct cached file size, we returned an impossible
allocation size.

Signed-off-by: Steve French <stfrench@microsoft.com>
CC: <stable@vger.kernel.org>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
fs/cifs/inode.c