On Tue, Oct 09, 2018 at 05:11:13PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <[email protected]>
> 
> Move the file range checks from vfs_clone_file_prep into a separate
> generic_remap_checks function so that all the checks are collected in a
> central location.  This forms the basis for adding more checks from
> generic_write_checks that will make cloning's input checking more
> consistent with write input checking.
> 
> Signed-off-by: Darrick J. Wong <[email protected]>
> Reviewed-by: Christoph Hellwig <[email protected]>
....
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -1717,12 +1717,12 @@ static int clone_verify_area(struct file *file, 
> loff_t pos, u64 len, bool write)
>   * Returns: 0 for "nothing to clone", 1 for "something to clone", or
>   * the usual negative error code.
>   */
> -int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in,
> -                            struct inode *inode_out, loff_t pos_out,
> -                            u64 *len, bool is_dedupe)
> +int vfs_clone_file_prep(struct file *file_in, loff_t pos_in,
> +                     struct file *file_out, loff_t pos_out,
> +                     u64 *len, bool is_dedupe)
>  {
> -     loff_t bs = inode_out->i_sb->s_blocksize;
> -     loff_t blen;
> +     struct inode *inode_in = file_inode(file_in);
> +     struct inode *inode_out = file_inode(file_out);
>       loff_t isize;
>       bool same_inode = (inode_in == inode_out);
>       int ret;
> @@ -1740,10 +1740,7 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, 
> loff_t pos_in,
>       if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
>               return -EINVAL;
>  
> -     /* Are we going all the way to the end? */
>       isize = i_size_read(inode_in);
> -     if (isize == 0)
> -             return 0;

This looks like a change of behaviour. Instead of skipping zero
legnth source files and returning success, this will now return
-EINVAL as other checks fail? That needs to be documented in the
commit message if it's intentional and a valid change to make...

Cheers,

Dave.
-- 
Dave Chinner
[email protected]

Reply via email to