Skip to content

Commit c3a72bb

Browse files
dhowellssmfrench
authored andcommitted
smb3: Move the flush out of smb2_copychunk_range() into its callers
Move the flush out of smb2_copychunk_range() into its callers. This will allow the pagecache to be invalidated between the flush and the operation in smb3_collapse_range() and smb3_insert_range(). Signed-off-by: David Howells <[email protected]> cc: Ronnie Sahlberg <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b90cb10 commit c3a72bb

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

fs/cifs/cifsfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,8 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
12191219

12201220
cifs_dbg(FYI, "copychunk range\n");
12211221

1222+
filemap_write_and_wait(src_inode->i_mapping);
1223+
12221224
if (!src_file->private_data || !dst_file->private_data) {
12231225
rc = -EBADF;
12241226
cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");

fs/cifs/smb2ops.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,17 +1600,8 @@ smb2_copychunk_range(const unsigned int xid,
16001600
int chunks_copied = 0;
16011601
bool chunk_sizes_updated = false;
16021602
ssize_t bytes_written, total_bytes_written = 0;
1603-
struct inode *inode;
16041603

16051604
pcchunk = kmalloc(sizeof(struct copychunk_ioctl), GFP_KERNEL);
1606-
1607-
/*
1608-
* We need to flush all unwritten data before we can send the
1609-
* copychunk ioctl to the server.
1610-
*/
1611-
inode = d_inode(trgtfile->dentry);
1612-
filemap_write_and_wait(inode->i_mapping);
1613-
16141605
if (pcchunk == NULL)
16151606
return -ENOMEM;
16161607

@@ -3694,6 +3685,8 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon,
36943685
goto out;
36953686
}
36963687

3688+
filemap_write_and_wait(inode->i_mapping);
3689+
36973690
rc = smb2_copychunk_range(xid, cfile, cfile, off + len,
36983691
i_size_read(inode) - off - len, off);
36993692
if (rc < 0)
@@ -3721,18 +3714,21 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon,
37213714
int rc;
37223715
unsigned int xid;
37233716
struct cifsFileInfo *cfile = file->private_data;
3717+
struct inode *inode = file_inode(file);
37243718
__le64 eof;
37253719
__u64 count;
37263720

37273721
xid = get_xid();
37283722

3729-
if (off >= i_size_read(file->f_inode)) {
3723+
if (off >= i_size_read(inode)) {
37303724
rc = -EINVAL;
37313725
goto out;
37323726
}
37333727

3734-
count = i_size_read(file->f_inode) - off;
3735-
eof = cpu_to_le64(i_size_read(file->f_inode) + len);
3728+
count = i_size_read(inode) - off;
3729+
eof = cpu_to_le64(i_size_read(inode) + len);
3730+
3731+
filemap_write_and_wait(inode->i_mapping);
37363732

37373733
rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
37383734
cfile->fid.volatile_fid, cfile->pid, &eof);

0 commit comments

Comments
 (0)