fs: use splice_copy_file_range() inline helper

generic_copy_file_range() is just a wrapper around splice_file_range(),
which caps the maximum copy length.

The only caller of splice_file_range(), namely __ceph_copy_file_range()
is already ready to cope with short copy.

Move the length capping into splice_file_range() and replace the exported
symbol generic_copy_file_range() with a simple inline helper.

Suggested-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/linux-fsdevel/20231204083849.GC32438@lst.de/
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Link: https://lore.kernel.org/r/20231212094440.250945-3-amir73il@gmail.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Amir Goldstein
2023-12-12 11:44:37 +02:00
committed by Christian Brauner
parent 0f292086c2
commit 705bcfcbde
8 changed files with 22 additions and 48 deletions

View File

@@ -1244,7 +1244,7 @@ EXPORT_SYMBOL(do_splice_direct);
* @len: number of bytes to splice
*
* Description:
* For use by generic_copy_file_range() and ->copy_file_range() methods.
* For use by ->copy_file_range() methods.
* Like do_splice_direct(), but vfs_copy_file_range() already holds
* start_file_write() on @out file.
*
@@ -1255,8 +1255,9 @@ ssize_t splice_file_range(struct file *in, loff_t *ppos, struct file *out,
{
lockdep_assert(file_write_started(out));
return do_splice_direct_actor(in, ppos, out, opos, len, 0,
splice_file_range_actor);
return do_splice_direct_actor(in, ppos, out, opos,
min_t(size_t, len, MAX_RW_COUNT),
0, splice_file_range_actor);
}
EXPORT_SYMBOL(splice_file_range);