summaryrefslogtreecommitdiffstats
path: root/drivers/acpi/nfit.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2024-08-23 14:22:42 +0100
committerSteve French <stfrench@microsoft.com>2024-08-25 09:06:25 -0500
commit416871f4fb84bc96822562e654941d5625a25bf8 (patch)
treeefda5de2f7b6d112f82b47254400a899b3e8b576 /drivers/acpi/nfit.c
parent017d1701743657fbfaea74397727a9d2b81846b7 (diff)
downloadlinux-416871f4fb84bc96822562e654941d5625a25bf8.tar.gz
linux-416871f4fb84bc96822562e654941d5625a25bf8.tar.bz2
linux-416871f4fb84bc96822562e654941d5625a25bf8.zip
cifs: Fix FALLOC_FL_PUNCH_HOLE support
The cifs filesystem doesn't quite emulate FALLOC_FL_PUNCH_HOLE correctly (note that due to lack of protocol support, it can't actually implement it directly). Whilst it will (partially) invalidate dirty folios in the pagecache, it doesn't write them back first, and so the EOF marker on the server may be lower than inode->i_size. This presents a problem, however, as if the punched hole invalidates the tail of the locally cached dirty data, writeback won't know it needs to move the EOF over to account for the hole punch (which isn't supposed to move the EOF). We could just write zeroes over the punched out region of the pagecache and write that back - but this is supposed to be a deallocatory operation. Fix this by manually moving the EOF over on the server after the operation if the hole punched would corrupt it. Note that the FSCTL_SET_ZERO_DATA RPC and the setting of the EOF should probably be compounded to stop a third party interfering (or, at least, massively reduce the chance). This was reproducible occasionally by using fsx with the following script: truncate 0x0 0x375e2 0x0 punch_hole 0x2f6d3 0x6ab5 0x375e2 truncate 0x0 0x3a71f 0x375e2 mapread 0xee05 0xcf12 0x3a71f write 0x2078e 0x5604 0x3a71f write 0x3ebdf 0x1421 0x3a71f * punch_hole 0x379d0 0x8630 0x40000 * mapread 0x2aaa2 0x85b 0x40000 fallocate 0x1b401 0x9ada 0x40000 read 0x15f2 0x7d32 0x40000 read 0x32f37 0x7a3b 0x40000 * The second "write" should extend the EOF to 0x40000, and the "punch_hole" should operate inside of that - but that depends on whether the VM gets in and writes back the data first. If it doesn't, the file ends up 0x3a71f in size, not 0x40000. Fixes: 31742c5a3317 ("enable fallocate punch hole ("fallocate -p") for SMB3") Signed-off-by: David Howells <dhowells@redhat.com> cc: Steve French <sfrench@samba.org> cc: Paulo Alcantara <pc@manguebit.com> cc: Shyam Prasad N <nspmangalore@gmail.com> cc: Jeff Layton <jlayton@kernel.org> cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'drivers/acpi/nfit.c')
0 files changed, 0 insertions, 0 deletions