Skip to content

Commit f5d0f92

Browse files
Ronnie SahlbergSteve French
authored andcommitted
cifs: destage any unwritten data to the server before calling copychunk_write
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>
1 parent cd70a3e commit f5d0f92

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/cifs/smb2ops.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,9 +1858,17 @@ smb2_copychunk_range(const unsigned int xid,
18581858
int chunks_copied = 0;
18591859
bool chunk_sizes_updated = false;
18601860
ssize_t bytes_written, total_bytes_written = 0;
1861+
struct inode *inode;
18611862

18621863
pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);
18631864

1865+
/*
1866+
* We need to flush all unwritten data before we can send the
1867+
* copychunk ioctl to the server.
1868+
*/
1869+
inode = d_inode(trgtfile->dentry);
1870+
filemap_write_and_wait(inode->i_mapping);
1871+
18641872
if (pcchunk == NULL)
18651873
return -ENOMEM;
18661874

0 commit comments

Comments
 (0)