@@ -1341,7 +1341,6 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
1341
1341
struct cifsFileInfo * smb_file_target ;
1342
1342
struct cifs_tcon * src_tcon ;
1343
1343
struct cifs_tcon * target_tcon ;
1344
- unsigned long long destend , fstart , fend ;
1345
1344
ssize_t rc ;
1346
1345
1347
1346
cifs_dbg (FYI , "copychunk range\n" );
@@ -1391,25 +1390,13 @@ ssize_t cifs_file_copychunk_range(unsigned int xid,
1391
1390
goto unlock ;
1392
1391
}
1393
1392
1394
- destend = destoff + len - 1 ;
1395
-
1396
- /* Flush the folios at either end of the destination range to prevent
1397
- * accidental loss of dirty data outside of the range.
1393
+ /* Flush and invalidate all the folios in the destination region. If
1394
+ * the copy was successful, then some of the flush is extra overhead,
1395
+ * but we need to allow for the copy failing in some way (eg. ENOSPC).
1398
1396
*/
1399
- fstart = destoff ;
1400
- fend = destend ;
1401
-
1402
- rc = cifs_flush_folio (target_inode , destoff , & fstart , & fend , true);
1397
+ rc = filemap_invalidate_inode (target_inode , true, destoff , destoff + len - 1 );
1403
1398
if (rc )
1404
1399
goto unlock ;
1405
- rc = cifs_flush_folio (target_inode , destend , & fstart , & fend , false);
1406
- if (rc )
1407
- goto unlock ;
1408
- if (fend > target_cifsi -> netfs .zero_point )
1409
- target_cifsi -> netfs .zero_point = fend + 1 ;
1410
-
1411
- /* Discard all the folios that overlap the destination region. */
1412
- truncate_inode_pages_range (& target_inode -> i_data , fstart , fend );
1413
1400
1414
1401
fscache_invalidate (cifs_inode_cookie (target_inode ), NULL ,
1415
1402
i_size_read (target_inode ), 0 );
0 commit comments