linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adam Borowski <kilobyte@angband.pl>
To: Nikolay Borisov <nborisov@suse.com>
Cc: David Sterba <dsterba@suse.cz>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/2] btrfs-progs: defrag: open files RO on new enough kernels or if root
Date: Mon, 3 Sep 2018 13:28:48 +0200	[thread overview]
Message-ID: <20180903112848.dinguob7clx4m6g7@angband.pl> (raw)
In-Reply-To: <61784cbe-719b-a83f-8535-bb622c39edcb@suse.com>

On Mon, Sep 03, 2018 at 02:04:23PM +0300, Nikolay Borisov wrote:
> On  3.09.2018 13:14, Adam Borowski wrote:
> > -		fd = open(fpath, O_RDWR);
> > +		fd = open(fpath, defrag_ro);
> 
> Looking at the kernel code I think this is in fact incorrect, because in
> ioctl.c we have:
> 
>                 if (!(file->f_mode & FMODE_WRITE)) {
> 
>                         ret = -EINVAL;
> 
>                         goto out;
> 
>                 }
> 
> So it seems a hard requirement to have opened a file for RW when you
> want to defragment it.

Oif!  I confused this with dedup, which does allow root to dedup RO even on
old kernels.  Good catch.


-- 
⢀⣴⠾⠻⢶⣦⠀ What Would Jesus Do, MUD/MMORPG edition:
⣾⠁⢰⠒⠀⣿⡁ • multiplay with an admin char to benefit your mortal [Mt3:16-17]
⢿⡄⠘⠷⠚⠋⠀ • abuse item cloning bugs [Mt14:17-20, Mt15:34-37]
⠈⠳⣄⠀⠀⠀⠀ • use glitches to walk on water [Mt14:25-26]

      reply	other threads:[~2018-09-03 15:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03 10:14 [PATCH 1/2] btrfs-progs: fix kernel version parsing on some versions past 3.0 Adam Borowski
2018-09-03 10:14 ` [PATCH 2/2] btrfs-progs: defrag: open files RO on new enough kernels or if root Adam Borowski
2018-09-03 11:01   ` Nikolay Borisov
2018-09-03 11:12     ` Adam Borowski
2018-09-03 11:31     ` [PATCH v2] btrfs-progs: defrag: open files RO on new enough kernels Adam Borowski
2018-09-03 11:41       ` Nikolay Borisov
2018-09-03 11:46         ` [PATCH v3] " Adam Borowski
2018-09-03 11:04   ` [PATCH 2/2] btrfs-progs: defrag: open files RO on new enough kernels or if root Nikolay Borisov
2018-09-03 11:28     ` Adam Borowski [this message]

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=20180903112848.dinguob7clx4m6g7@angband.pl \
    --to=kilobyte@angband.pl \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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 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).