linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: allow FILE_EXTENT_SAME (dedupe_file_range) on a file opened ro
@ 2016-07-17 22:13 Adam Borowski
  2016-07-17 22:32 ` Adam Borowski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Adam Borowski @ 2016-07-17 22:13 UTC (permalink / raw)
  To: Alexander Viro, linux-fsdevel, linux-kernel, linux-btrfs,
	Mark Fasheh, Darrick J . Wong
  Cc: Adam Borowski

Instead of checking the mode of the file descriptor, let's check whether it
could have been opened rw.  This allows fixing intermittent exec failures
when deduping a live system: anyone trying to exec a file currently being
deduped gets ETXTBSY.

Issuing this ioctl on a ro file was already allowed for root/cap.

Tested on btrfs and not-yet-merged xfs, as only them implement this ioctl.

Signed-off-by: Adam Borowski <kilobyte@angband.pl>
---
 fs/read_write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/read_write.c b/fs/read_write.c
index 933b53a..df59dc6 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1723,7 +1723,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
 
 		if (info->reserved) {
 			info->status = -EINVAL;
-		} else if (!(is_admin || (dst_file->f_mode & FMODE_WRITE))) {
+		} else if (!(is_admin || !inode_permission(dst, MAY_WRITE))) {
 			info->status = -EINVAL;
 		} else if (file->f_path.mnt != dst_file->f_path.mnt) {
 			info->status = -EXDEV;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-19  2:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-17 22:13 [PATCH] vfs: allow FILE_EXTENT_SAME (dedupe_file_range) on a file opened ro Adam Borowski
2016-07-17 22:32 ` Adam Borowski
2016-07-18 19:51 ` Mark Fasheh
2016-07-19  2:41 ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).