linux/fs/smb/client
David Howells 91d1dfae46 cifs: Fix FALLOC_FL_ZERO_RANGE to preflush buffered part of target region
Under certain conditions, the range to be cleared by FALLOC_FL_ZERO_RANGE
may only be buffered locally and not yet have been flushed to the server.
For example:

	xfs_io -f -t -c "pwrite -S 0x41 0 4k" \
		     -c "pwrite -S 0x42 4k 4k" \
		     -c "fzero 0 4k" \
		     -c "pread -v 0 8k" /xfstest.test/foo

will write two 4KiB blocks of data, which get buffered in the pagecache,
and then fallocate() is used to clear the first 4KiB block on the server -
but we don't flush the data first, which means the EOF position on the
server is wrong, and so the FSCTL_SET_ZERO_DATA RPC fails (and xfs_io
ignores the error), but then when we try to read it, we see the old data.

Fix this by preflushing any part of the target region that above the
server's idea of the EOF position to force the server to update its EOF
position.

Note, however, that we don't want to simply expand the file by moving the
EOF before doing the FSCTL_SET_ZERO_DATA[*] because someone else might see
the zeroed region or if the RPC fails we then have to try to clean it up or
risk getting corruption.

[*] And we have to move the EOF first otherwise FSCTL_SET_ZERO_DATA won't
do what we want.

This fixes the generic/008 xfstest.

[!] Note: A better way to do this might be to split the operation into two
parts: we only do FSCTL_SET_ZERO_DATA for the part of the range below the
server's EOF and then, if that worked, invalidate the buffered pages for the
part above the range.

Fixes: 6b69040247 ("cifs/smb3: Fix data inconsistent when zero file range")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Steve French <stfrench@microsoft.com>
cc: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
cc: Pavel Shilovsky <pshilov@microsoft.com>
cc: Paulo Alcantara <pc@manguebit.com>
cc: Shyam Prasad N <nspmangalore@gmail.com>
cc: Rohith Surabattula <rohiths.msft@gmail.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-cifs@vger.kernel.org
cc: linux-mm@kvack.org
Signed-off-by: Steve French <stfrench@microsoft.com>
2024-08-28 16:52:17 -05:00
..
asn1.c
cached_dir.c smb3: fix Open files on server counter going negative 2024-04-11 16:02:02 -05:00
cached_dir.h smb: client: make laundromat a delayed worker 2023-10-12 09:41:04 -05:00
cifs_debug.c smb3: fix setting SecurityFlags when encryption is required 2024-08-08 11:14:53 -05:00
cifs_debug.h
cifs_fs_sb.h
cifs_ioctl.h smb3: allow dumping session and tcon id to improve stats analysis and debugging 2023-11-10 02:00:30 -06:00
cifs_spnego_negtokeninit.asn1
cifs_spnego.c cifs: spnego: add ';' in HOST_KEY_LEN 2023-11-13 16:21:34 -06:00
cifs_spnego.h
cifs_swn.c
cifs_swn.h
cifs_unicode.c fs/smb/client: Use common code in client 2023-08-30 08:55:52 -05:00
cifs_unicode.h fs/smb/client: Use common code in client 2023-08-30 08:55:52 -05:00
cifsacl.c
cifsacl.h
cifsencrypt.c smb: Work around Clang __bdos() type confusion 2024-01-23 18:56:16 -06:00
cifsfs.c cifs: Fix copy offload to flush destination region 2024-08-28 07:48:33 -05:00
cifsfs.h cifs: update internal version number 2024-08-02 10:56:14 -05:00
cifsglob.h cifs: Fix lack of credit renegotiation on read retry 2024-08-28 07:47:36 -05:00
cifspdu.h cifs: fix creating sockets when using sfu mount options 2024-05-31 10:55:15 -05:00
cifsproto.h cifs: Remove cifs_aio_ctx 2024-08-02 10:55:45 -05:00
cifsroot.c
cifssmb.c smb/client: remove unused rq_iter_size from struct smb_rqst 2024-08-25 09:06:25 -05:00
connect.c smb3: fix problem unloading module due to leaked refcount on shutdown 2024-08-22 12:36:57 -05:00
dfs_cache.c smb: client: refresh referral without acquiring refpath_lock 2024-04-02 10:11:43 -05:00
dfs_cache.h smb: client: ensure to try all targets when finding nested links 2023-08-20 16:05:50 -05:00
dfs.c smb: client: guarantee refcounted children from parent session 2024-04-02 10:09:57 -05:00
dfs.h smb: client: guarantee refcounted children from parent session 2024-04-02 10:09:57 -05:00
dir.c cifs: Fix caching to try to do open O_WRONLY as rdwr on server 2024-04-02 09:29:55 -05:00
dns_resolve.c
dns_resolve.h
export.c exportfs: make ->encode_fh() a mandatory method for NFS export 2023-10-28 16:15:15 +02:00
file.c cifs: Fix lack of credit renegotiation on read retry 2024-08-28 07:47:36 -05:00
fs_context.c smb: client: Convert to new uid/gid option parsing helpers 2024-07-02 06:21:20 +02:00
fs_context.h cifs: reinstate original behavior again for forceuid/forcegid 2024-04-22 10:50:31 -05:00
fscache.c cifs: Remove some code that's no longer used, part 1 2024-05-01 18:08:21 +01:00
fscache.h cifs: Remove some code that's no longer used, part 1 2024-05-01 18:08:21 +01:00
inode.c smb: client: handle lack of FSCTL_GET_REPARSE_POINT support 2024-08-02 10:55:22 -05:00
ioctl.c smb3: fix problem unloading module due to leaked refcount on shutdown 2024-08-22 12:36:57 -05:00
Kconfig cifs: Implement netfslib hooks 2024-05-01 18:08:21 +01:00
link.c smb3: fix problem unloading module due to leaked refcount on shutdown 2024-08-22 12:36:57 -05:00
Makefile smb: client: move most of reparse point handling code to common file 2024-03-10 19:33:57 -05:00
misc.c cifs: cifs_inval_name_dfs_link_error: correct the check for fullpath 2024-08-08 20:06:22 -05:00
namespace.c smb: client: set correct id, uid and cruid for multiuser automounts 2024-02-12 12:46:49 -06:00
netlink.c
netlink.h
netmisc.c
nterr.c
nterr.h
ntlmssp.h cifs: Add client version details to NTLM authenticate message 2023-10-22 19:03:42 -05:00
readdir.c smb: client: parse uid, gid, mode and dev from WSL reparse points 2024-03-10 19:33:58 -05:00
reparse.c smb: client: ignore unhandled reparse tags 2024-08-22 12:37:16 -05:00
reparse.h smb: client: handle lack of FSCTL_GET_REPARSE_POINT support 2024-08-02 10:55:22 -05:00
rfc1002pdu.h
sess.c cifs: reduce warning log level for server not advertising interfaces 2024-03-14 13:54:27 -05:00
smb1ops.c cifs: Add a tracepoint to track credits involved in R/W requests 2024-07-19 11:08:57 -05:00
smb2file.c smb/client: adapt to breakup of struct file_lock 2024-02-05 13:11:44 +01:00
smb2glob.h smb: client: introduce SMB2_OP_QUERY_WSL_EA 2024-03-10 19:33:58 -05:00
smb2inode.c smb: client: fix FSCTL_GET_REPARSE_POINT against NetApp 2024-08-02 10:56:02 -05:00
smb2maperror.c cifs: new nt status codes from MS-SMB2 2024-01-18 21:01:04 -06:00
smb2misc.c cifs: Add tracing for the cifs_tcon struct refcounting 2024-04-19 16:02:09 -05:00
smb2ops.c cifs: Fix FALLOC_FL_ZERO_RANGE to preflush buffered part of target region 2024-08-28 16:52:17 -05:00
smb2pdu.c netfs, cifs: Fix handling of short DIO read 2024-08-28 07:47:36 -05:00
smb2pdu.h smb: smb2pdu.h: Avoid -Wflex-array-member-not-at-end warnings 2024-05-13 16:46:56 -05:00
smb2proto.h cifs: Cut over to using netfslib 2024-05-01 18:08:21 +01:00
smb2status.h cifs: new nt status codes from MS-SMB2 2024-01-18 21:01:04 -06:00
smb2transport.c smb: client: fix deadlock in smb2_find_smb_tcon() 2024-06-07 01:05:07 -05:00
smbdirect.c Fix spelling errors in Server Message Block 2024-08-08 11:15:33 -05:00
smbdirect.h
smbencrypt.c smb: client: delete "true", "false" defines 2024-01-23 12:41:02 -06:00
smberr.h
trace.c
trace.h cifs: Fix lack of credit renegotiation on read retry 2024-08-28 07:47:36 -05:00
transport.c Fix spelling errors in Server Message Block 2024-08-08 11:15:33 -05:00
unc.c
winucase.c
xattr.c smb3: fix caching of ctime on setxattr 2023-11-09 10:25:58 -06:00