Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 3/4] btrfs: exclude mmaps while doing remap
Date: Tue, 15 Dec 2020 15:40:02 -0500	[thread overview]
Message-ID: <6bc7fdb7-7c8f-92ec-e320-d1878b0b4584@toxicpanda.com> (raw)
In-Reply-To: <20201215202315.GA6905@magnolia>

On 12/15/20 3:23 PM, Darrick J. Wong wrote:
> On Mon, Dec 14, 2020 at 01:19:40PM -0500, Josef Bacik wrote:
>> Darrick reported a potential issue to me where we could allow mmap
>> writes after validating a page range matched in the case of dedupe.
>> Generally we rely on lock page -> lock extent with the ordered flush to
>> protect us, but this is done after we check the pages because we use the
>> generic helpers, so we could modify the page in between doing the check
>> and locking the range.
> 
> FWIW I only found that via code inspection because Matthew Wilcox asked
> me about whether or not filesystems did the right thing.  I wrote the
> attached fstest to try to demonstrate the problem on btrfs but it
> actually passes on xfs and btrfs.  This means either that (a) btrfs is
> doing it right through some other means because I don't understand its
> locking or (b) the test is wrong.
> 
> The test /does/ explode as expected on ocfs2 because mmap io lol there.
> 

The problem exists, it's just the window is super narrow.  If you put a 
schedule_timeout(HZ) right after btrfs_remap_file_range_prep() you'd hit the 
problem every time.  We basically have to mkwrite right between doing the 
vfs_dedupe_file_range_compare() and calling btrfs_extent_same(), which is going 
to be hard to do.  You aren't missing something, it's just hard to hit.  Thanks,

Josef

  reply	other threads:[~2020-12-15 20:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-14 18:19 [PATCH 0/4] Introduce a mmap sem to deal with some mmap issues Josef Bacik
2020-12-14 18:19 ` [PATCH 1/4] btrfs: add a i_mmap_lock to our inode Josef Bacik
2020-12-14 18:19 ` [PATCH 2/4] btrfs: cleanup inode_lock/inode_unlock uses Josef Bacik
2020-12-14 18:19 ` [PATCH 3/4] btrfs: exclude mmaps while doing remap Josef Bacik
2020-12-15 20:23   ` Darrick J. Wong
2020-12-15 20:40     ` Josef Bacik [this message]
2020-12-14 18:19 ` [PATCH 4/4] btrfs: exclude mmap from happening during all fallocate operations Josef Bacik
2020-12-23  8:19 ` [PATCH 0/4] Introduce a mmap sem to deal with some mmap issues Christoph Hellwig

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=6bc7fdb7-7c8f-92ec-e320-d1878b0b4584@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=darrick.wong@oracle.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox