]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
cifs: destage any unwritten data to the server before calling copychunk_write
authorRonnie Sahlberg <lsahlber@redhat.com>
Thu, 21 Apr 2022 01:15:36 +0000 (11:15 +1000)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 22 Jun 2022 12:22:57 +0000 (14:22 +0200)
commita502c2be2402935f21e25ec6914107ef61deac71
tree12d93f0cba9958f196b47f1994f722da65952c25
parent92cedfca7b1d5a156f372ef68f4de89db0f96f71
cifs: destage any unwritten data to the server before calling copychunk_write

BugLink: https://bugs.launchpad.net/bugs/1978234
[ Upstream commit f5d0f921ea362636e4a2efb7c38d1ead373a8700 ]

because the copychunk_write might cover a region of the file that has not yet
been sent to the server and thus fail.

A simple way to reproduce this is:
truncate -s 0 /mnt/testfile; strace -f -o x -ttT xfs_io -i -f -c 'pwrite 0k 128k' -c 'fcollapse 16k 24k' /mnt/testfile

the issue is that the 'pwrite 0k 128k' becomes rearranged on the wire with
the 'fcollapse 16k 24k' due to write-back caching.

fcollapse is implemented in cifs.ko as a SMB2 IOCTL(COPYCHUNK_WRITE) call
and it will fail serverside since the file is still 0b in size serverside
until the writes have been destaged.
To avoid this we must ensure that we destage any unwritten data to the
server before calling COPYCHUNK_WRITE.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1997373
Reported-by: Xiaoli Feng <xifeng@redhat.com>
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/cifs/smb2ops.c