smb3: do not error on fsync when readonly
authorSteve French <stfrench@microsoft.com>
Wed, 10 Nov 2021 07:47:48 +0000 (01:47 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Nov 2021 10:04:44 +0000 (11:04 +0100)
commita6e210f38fd996ece0f86caeb7bab992c3934b03
tree1245f595c524c334c3a370413286f2d6c7e37d57
parent05f3204178239aa629edbad650cd21c1e683beae
smb3: do not error on fsync when readonly

commit 71e6864eacbef0b2645ca043cdfbac272cb6cea3 upstream.

Linux allows doing a flush/fsync on a file open for read-only,
but the protocol does not allow that.  If the file passed in
on the flush is read-only try to find a writeable handle for
the same inode, if that is not possible skip sending the
fsync call to the server to avoid breaking the apps.

Reported-by: Julian Sikorski <belegdol@gmail.com>
Tested-by: Julian Sikorski <belegdol@gmail.com>
Suggested-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/cifs/file.c