ksmbd: remove unnecessary generic_fillattr in smb2_open
authorHyunchul Lee <hyc.lee@gmail.com>
Fri, 12 Aug 2022 02:11:32 +0000 (11:11 +0900)
committerSteve French <stfrench@microsoft.com>
Tue, 16 Aug 2022 02:06:54 +0000 (21:06 -0500)
commitc90b31eaf9e77269d3803ed9223a2e0168b519ac
tree351bcf309289bc7e04301491d866287638b4a419
parent4963d74f8a6cc0eafd71d9ffc13e3a11ff1dd160
ksmbd: remove unnecessary generic_fillattr in smb2_open

Remove unnecessary generic_fillattr to fix wrong
AllocationSize of SMB2_CREATE response, And
Move the call of ksmbd_vfs_getattr above the place
where stat is needed because of truncate.

This patch fixes wrong AllocationSize of SMB2_CREATE
response. Because ext4 updates inode->i_blocks only
when disk space is allocated, generic_fillattr does
not set stat.blocks properly for delayed allocation.
But ext4 returns the blocks that include the delayed
allocation blocks when getattr is called.

The issue can be reproduced with commands below:

touch ${FILENAME}
xfs_io -c "pwrite -S 0xAB 0 40k" ${FILENAME}
xfs_io -c "stat" ${FILENAME}

40KB are written, but the count of blocks is 8.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/ksmbd/smb2pdu.c