Commit 3758c485 authored by David Howells's avatar David Howells

cifs: Set zero_point in the copy_file_range() and remap_file_range()

Set zero_point in the copy_file_range() and remap_file_range()
implementations so that we don't skip reading data modified on a
server-side copy.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
cc: Steve French <sfrench@samba.org>
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: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
parent 1a5b4edd
...@@ -1287,6 +1287,8 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, ...@@ -1287,6 +1287,8 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
rc = cifs_flush_folio(target_inode, destend, &fstart, &fend, false); rc = cifs_flush_folio(target_inode, destend, &fstart, &fend, false);
if (rc) if (rc)
goto unlock; goto unlock;
if (fend > target_cifsi->netfs.zero_point)
target_cifsi->netfs.zero_point = fend + 1;
/* Discard all the folios that overlap the destination region. */ /* Discard all the folios that overlap the destination region. */
cifs_dbg(FYI, "about to discard pages %llx-%llx\n", fstart, fend); cifs_dbg(FYI, "about to discard pages %llx-%llx\n", fstart, fend);
...@@ -1305,6 +1307,8 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, ...@@ -1305,6 +1307,8 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
fscache_resize_cookie(cifs_inode_cookie(target_inode), fscache_resize_cookie(cifs_inode_cookie(target_inode),
new_size); new_size);
} }
if (rc == 0 && new_size > target_cifsi->netfs.zero_point)
target_cifsi->netfs.zero_point = new_size;
} }
/* force revalidate of size and timestamps of target file now /* force revalidate of size and timestamps of target file now
...@@ -1396,6 +1400,8 @@ ssize_t cifs_file_copychunk_range(unsigned int xid, ...@@ -1396,6 +1400,8 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
rc = cifs_flush_folio(target_inode, destend, &fstart, &fend, false); rc = cifs_flush_folio(target_inode, destend, &fstart, &fend, false);
if (rc) if (rc)
goto unlock; goto unlock;
if (fend > target_cifsi->netfs.zero_point)
target_cifsi->netfs.zero_point = fend + 1;
/* Discard all the folios that overlap the destination region. */ /* Discard all the folios that overlap the destination region. */
truncate_inode_pages_range(&target_inode->i_data, fstart, fend); truncate_inode_pages_range(&target_inode->i_data, fstart, fend);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment