Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 494633fa authored by Dave Chinner's avatar Dave Chinner Committed by Darrick J. Wong
Browse files

vfs: vfs_dedupe_file_range() doesn't return EOPNOTSUPP



It returns EINVAL when the operation is not supported by the
filesystem. Fix it to return EOPNOTSUPP to be consistent with
the man page and clone_file_range().

Clean up the inconsistent error return handling while I'm there.
(I know, lipstick on a pig, but every little bit helps...)

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 4721a601
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -2094,17 +2094,18 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
	off = same->src_offset;
	len = same->src_length;

	ret = -EISDIR;
	if (S_ISDIR(src->i_mode))
		goto out;
		return -EISDIR;

	ret = -EINVAL;
	if (!S_ISREG(src->i_mode))
		goto out;
		return -EINVAL;

	if (!file->f_op->remap_file_range)
		return -EOPNOTSUPP;

	ret = remap_verify_area(file, off, len, false);
	if (ret < 0)
		goto out;
		return ret;
	ret = 0;

	if (off + len > i_size_read(src))
@@ -2147,10 +2148,8 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
		fdput(dst_fd);
next_loop:
		if (fatal_signal_pending(current))
			goto out;
			break;
	}

out:
	return ret;
}
EXPORT_SYMBOL(vfs_dedupe_file_range);