vfs: enable remap callers that can handle short operations
Plumb in a remap flag that enables the filesystem remap handler to shorten remapping requests for callers that can handle it. Now copy_file_range can report partial success (in case we run up against alignment problems, resource limits, etc.). We also enable CAN_SHORTEN for fideduperange to maintain existing userspace-visible behavior where xfs/btrfs shorten the dedupe range to avoid stale post-eof data exposure. 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:

committed by
Dave Chinner

parent
df36583619
commit
eca3654e3c
11
mm/filemap.c
11
mm/filemap.c
@@ -3045,8 +3045,7 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in,
|
||||
bcount = ALIGN(size_in, bs) - pos_in;
|
||||
} else {
|
||||
if (!IS_ALIGNED(count, bs))
|
||||
return -EINVAL;
|
||||
|
||||
count = ALIGN_DOWN(count, bs);
|
||||
bcount = count;
|
||||
}
|
||||
|
||||
@@ -3056,10 +3055,14 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in,
|
||||
pos_out < pos_in + bcount)
|
||||
return -EINVAL;
|
||||
|
||||
/* For now we don't support changing the length. */
|
||||
if (*req_count != count)
|
||||
/*
|
||||
* We shortened the request but the caller can't deal with that, so
|
||||
* bounce the request back to userspace.
|
||||
*/
|
||||
if (*req_count != count && !(remap_flags & REMAP_FILE_CAN_SHORTEN))
|
||||
return -EINVAL;
|
||||
|
||||
*req_count = count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user