linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs,vfs: allow FILE_EXTENT_SAME on a file opened ro
@ 2016-05-20  3:45 Adam Borowski
  2016-05-26 22:57 ` Adam Borowski
  2016-05-27  0:04 ` Mark Fasheh
  0 siblings, 2 replies; 9+ messages in thread
From: Adam Borowski @ 2016-05-20  3:45 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-btrfs, linux-fsdevel
  Cc: Adam Borowski

(Only btrfs currently implements dedupe_file_range.)

Instead of checking the mode of the file descriptor, let's check whether
it could have been opened rw.  This allows fixing 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.

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 cf377cf..6c414d8 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -1736,7 +1736,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] 9+ messages in thread

end of thread, other threads:[~2016-05-30 12:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-20  3:45 [PATCH] btrfs,vfs: allow FILE_EXTENT_SAME on a file opened ro Adam Borowski
2016-05-26 22:57 ` Adam Borowski
2016-05-27  0:04 ` Mark Fasheh
2016-05-27  0:48   ` Adam Borowski
2016-05-28  1:59   ` Zygo Blaxell
2016-05-29  0:21     ` Adam Borowski
2016-05-29  0:56       ` Zygo Blaxell
2016-05-29  6:53         ` Andrei Borzenkov
2016-05-30 12:24         ` Adam Borowski

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).