[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1297339.1700862676@warthog.procyon.org.uk>
Date: Fri, 24 Nov 2023 21:51:16 +0000
From: David Howells <dhowells@...hat.com>
To: Steve French <sfrench@...ba.org>
cc: dhowells@...hat.com, Shyam Prasad N <nspmangalore@...il.com>,
Rohith Surabattula <rohiths.msft@...il.com>,
Jeff Layton <jlayton@...nel.org>, linux-cifs@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] cifs: Set the file size after doing copychunk_range
Set i_size on the inode after doing the copychunk_range operation as this
value may be used by various things internally. stat() hides the issue
because setting ->time to 0 causes cifs_getatr() to revalidate the
attributes.
Also reduce the pagecache truncation to only invalidate the range of bytes
that will be copied over otherwise we will discard dirty data that isn't
inside the target range.
Fixes: 620d8745b35d ("Introduce cifs_copy_file_range()")
Signed-off-by: David Howells <dhowells@...hat.com>
cc: Steve French <sfrench@...ba.org>
cc: Shyam Prasad N <nspmangalore@...il.com>
cc: Rohith Surabattula <rohiths.msft@...il.com>
cc: Jeff Layton <jlayton@...nel.org>
cc: linux-cifs@...r.kernel.org
---
fs/smb/client/cifsfs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index ea3a7a668b45..5a69e93c302e 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -1307,12 +1307,15 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
goto unlock;
/* should we flush first and last page first */
- truncate_inode_pages(&target_inode->i_data, 0);
+ truncate_inode_pages_range(&target_inode->i_data, destoff, len);
rc = file_modified(dst_file);
- if (!rc)
+ if (!rc) {
rc = target_tcon->ses->server->ops->copychunk_range(xid,
smb_file_src, smb_file_target, off, len, destoff);
+ if (rc > 0 && destoff + rc > i_size_read(target_inode))
+ truncate_setsize(target_inode, destoff + rc);
+ }
file_accessed(src_file);
Powered by blists - more mailing lists