diff options
| author | Darrick J. Wong <darrick.wong@oracle.com> | 2018-10-29 19:41:49 -0400 |
|---|---|---|
| committer | Dave Chinner <david@fromorbit.com> | 2018-10-29 19:41:49 -0400 |
| commit | 42ec3d4c02187a18e27ff94b409ec27234bf2ffd (patch) | |
| tree | c9db04db8187c370718a43e6067af0e5aa944500 /fs/ocfs2 | |
| parent | 8dde90bca6fca3736ea20109654bcf6dcf2ecf1d (diff) | |
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>
Diffstat (limited to 'fs/ocfs2')
| -rw-r--r-- | fs/ocfs2/file.c | 16 | ||||
| -rw-r--r-- | fs/ocfs2/refcounttree.c | 2 | ||||
| -rw-r--r-- | fs/ocfs2/refcounttree.h | 2 |
3 files changed, 10 insertions, 10 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 9809b0e5746f..fbaeafe44b5f 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
| @@ -2527,18 +2527,18 @@ out: | |||
| 2527 | return offset; | 2527 | return offset; |
| 2528 | } | 2528 | } |
| 2529 | 2529 | ||
| 2530 | static int ocfs2_remap_file_range(struct file *file_in, | 2530 | static loff_t ocfs2_remap_file_range(struct file *file_in, loff_t pos_in, |
| 2531 | loff_t pos_in, | 2531 | struct file *file_out, loff_t pos_out, |
| 2532 | struct file *file_out, | 2532 | loff_t len, unsigned int remap_flags) |
| 2533 | loff_t pos_out, | ||
| 2534 | u64 len, | ||
| 2535 | unsigned int remap_flags) | ||
| 2536 | { | 2533 | { |
| 2534 | int ret; | ||
| 2535 | |||
| 2537 | if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) | 2536 | if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) |
| 2538 | return -EINVAL; | 2537 | return -EINVAL; |
| 2539 | 2538 | ||
| 2540 | return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, | 2539 | ret = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, |
| 2541 | len, remap_flags); | 2540 | len, remap_flags); |
| 2541 | return ret < 0 ? ret : len; | ||
| 2542 | } | 2542 | } |
| 2543 | 2543 | ||
| 2544 | const struct inode_operations ocfs2_file_iops = { | 2544 | const struct inode_operations ocfs2_file_iops = { |
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index df9781567ec0..6a42c04ac0ab 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c | |||
| @@ -4824,7 +4824,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, | |||
| 4824 | loff_t pos_in, | 4824 | loff_t pos_in, |
| 4825 | struct file *file_out, | 4825 | struct file *file_out, |
| 4826 | loff_t pos_out, | 4826 | loff_t pos_out, |
| 4827 | u64 len, | 4827 | loff_t len, |
| 4828 | unsigned int remap_flags) | 4828 | unsigned int remap_flags) |
| 4829 | { | 4829 | { |
| 4830 | struct inode *inode_in = file_inode(file_in); | 4830 | struct inode *inode_in = file_inode(file_in); |
diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h index d2c5f526edff..eb65c1d0843c 100644 --- a/fs/ocfs2/refcounttree.h +++ b/fs/ocfs2/refcounttree.h | |||
| @@ -119,7 +119,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, | |||
| 119 | loff_t pos_in, | 119 | loff_t pos_in, |
| 120 | struct file *file_out, | 120 | struct file *file_out, |
| 121 | loff_t pos_out, | 121 | loff_t pos_out, |
| 122 | u64 len, | 122 | loff_t len, |
| 123 | unsigned int remap_flags); | 123 | unsigned int remap_flags); |
| 124 | 124 | ||
| 125 | #endif /* OCFS2_REFCOUNTTREE_H */ | 125 | #endif /* OCFS2_REFCOUNTTREE_H */ |
