All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Borowski <kilobyte@angband.pl>
To: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: Adam Borowski <kilobyte@angband.pl>
Subject: [PATCH] btrfs,vfs: allow FILE_EXTENT_SAME on a file opened ro
Date: Fri, 20 May 2016 05:45:12 +0200	[thread overview]
Message-ID: <1463715912-8005-1-git-send-email-kilobyte@angband.pl> (raw)

(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


             reply	other threads:[~2016-05-20  3:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20  3:45 Adam Borowski [this message]
2016-05-26 22:57 ` [PATCH] btrfs,vfs: allow FILE_EXTENT_SAME on a file opened ro 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463715912-8005-1-git-send-email-kilobyte@angband.pl \
    --to=kilobyte@angband.pl \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.