Message ID | 20180807214949.7714-1-mfasheh@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Aug 07, 2018 at 02:49:47PM -0700, Mark Fasheh wrote: > Hi Andrew, > > Could I please have these patches upstreamed or at least put in a tree for > more public testing? They've hit fsdevel a few times now, I have links to > the discussions in the change log below. > The first patch expands our check to allow dedupe of a file if the > user owns it or otherwise would be allowed to write to it. [...] > The other problem we have is also related to forcing the user to open > target files for write - A process trying to exec a file currently > being deduped gets ETXTBUSY. The answer (as above) is to allow them to > open the targets ro - root can already do this. There was a patch from > Adam Borowski to fix this back in 2016 > The 2nd patch fixes our return code for permission denied to be > EPERM. For some reason we're returning EINVAL - I think that's > probably my fault. At any rate, we need to be returning something > descriptive of the actual problem, otherwise callers see EINVAL and > can't really make a valid determination of what's gone wrong. Note that the counterpart of these two patches for BTRFS_IOC_DEFRAG, which fixes the same issues, is included in btrfs' for-next, slated for 4.19. While technically dedupe and defrag are independent, there would be somewhat less confusion if both behave the same in the same kernel version. Thus, it'd be nice if you would consider taking this. Should be safe: even the permission check is paranoid. Meow!
diff --git a/man2/ioctl_fideduperange.2 b/man2/ioctl_fideduperange.2 index 84d20a276..4040ee064 100644 --- a/man2/ioctl_fideduperange.2 +++ b/man2/ioctl_fideduperange.2 @@ -105,9 +105,12 @@ The field must be zero. During the call, .IR src_fd -must be open for reading and +must be open for reading. .IR dest_fd -must be open for writing. +can be open for writing, or reading. +If +.IR dest_fd +is open for reading, the user must have write access to the file. The combined size of the struct .IR file_dedupe_range and the struct @@ -185,8 +188,8 @@ This can appear if the filesystem does not support deduplicating either file descriptor, or if either file descriptor refers to special inodes. .TP .B EPERM -.IR dest_fd -is immutable. +This will be returned if the user lacks permission to dedupe the file referenced by +.IR dest_fd . .TP .B ETXTBSY One of the files is a swap file.