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>
Thu, 18 Nov 2021 18:17:13 +0000 (19:17 +0100)
commit93114d5b3af04be24e77cf771268955a89c4ba01
tree2628998a9d15874a7dfa33c0e5344e024aacf319
parentc3f2809643ad5aec73dafa5f69f172c80846ae0f
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