vfs: make remap_file_range functions take and return bytes completed

Change the remap_file_range functions to take a number of bytes to
operate upon and return the number of bytes they operated on.  This is a
requirement for allowing fs implementations to return short clone/dedupe
results to the user, which will enable us to obey resource limits in a
graceful manner.

A subsequent patch will enable copy_file_range to signal to the
->clone_file_range implementation that it can handle a short length,
which will be returned in the function's return value.  For now the
short return is not implemented anywhere so the behavior won't change --
either copy_file_range manages to clone the entire range or it tries an
alternative.

Neither clone ioctl can take advantage of this, alas.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Darrick J. Wong
2018-10-30 10:41:49 +11:00
committed by Dave Chinner
부모 8dde90bca6
커밋 42ec3d4c02
18개의 변경된 파일108개의 추가작업 그리고 82개의 파일을 삭제

파일 보기

@@ -2527,18 +2527,18 @@ out:
return offset;
}
static int ocfs2_remap_file_range(struct file *file_in,
loff_t pos_in,
struct file *file_out,
loff_t pos_out,
u64 len,
unsigned int remap_flags)
static loff_t ocfs2_remap_file_range(struct file *file_in, loff_t pos_in,
struct file *file_out, loff_t pos_out,
loff_t len, unsigned int remap_flags)
{
int ret;
if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
return -EINVAL;
return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out,
len, remap_flags);
ret = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out,
len, remap_flags);
return ret < 0 ? ret : len;
}
const struct inode_operations ocfs2_file_iops = {

파일 보기

@@ -4824,7 +4824,7 @@ int ocfs2_reflink_remap_range(struct file *file_in,
loff_t pos_in,
struct file *file_out,
loff_t pos_out,
u64 len,
loff_t len,
unsigned int remap_flags)
{
struct inode *inode_in = file_inode(file_in);

파일 보기

@@ -119,7 +119,7 @@ int ocfs2_reflink_remap_range(struct file *file_in,
loff_t pos_in,
struct file *file_out,
loff_t pos_out,
u64 len,
loff_t len,
unsigned int remap_flags);
#endif /* OCFS2_REFCOUNTTREE_H */