Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Filipe Manana <fdmanana@kernel.org>, Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH RFC v2] btrfs: disable direct reads to avoid dirty folios without fs knowing
Date: Thu, 23 Jul 2026 13:45:15 +0200	[thread overview]
Message-ID: <be2eff36-fbff-4451-9a63-84f95968370c@linux.ibm.com> (raw)
In-Reply-To: <CAL3q7H4yxeAXzh+hHBsiD0ovotWpcoaK2byvS_5qz2cJybhNoQ@mail.gmail.com>


Am 23.07.26 um 13:23 schrieb Filipe Manana:
> On Thu, Jul 23, 2026 at 12:17 PM Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
>>
>>
>>
>> 在 2026/7/23 20:08, Filipe Manana 写道:
>>> On Thu, Jul 23, 2026 at 7:16 AM Qu Wenruo <wqu@suse.com> wrote:
>>>>
>>>> There is a bug report that a reproducer which doing the following
>>>> workloads in two threads:
>>>>
>>>> - Direct read into memory mapped from page cache
>>>> - Sync the above range
>>>>
>>>> This can lead to dirty folios without fs knowing, this can be a huge
>>>
>>> Can you please explain where, and why, the folio is dirtied?
>>
>>
>> btrfs_check_read_bio()
>> |- __iomap_dio_bio_end_io() from btrfs_bio_end_io()
>>      |- bio_check_pages_dirty()
>>         |- bio_dirty_fn()
>>            |- bio_release_pages(bio, true)
>>               |- __bio_release_pages(bio, mark_dirty == true)
>>                  |- folio_mark_dirty()
>>
>> At least this is the one from the reproducer.
> 
> That should be part of the change log, it's not obvious at all.
> I also wonder why a direct IO read dirties the folio if it's not
> supposed to change file data.
> 
>>
See also the initial discussion here
https://lore.kernel.org/linux-s390/79b9b1b2-0455-4a7c-85fd-929f4103f198@gmx.com/T/#m31c388aa6bbfb77c689ff95b5a35c4db5fc231c3

In essence any gup+set_page_dirty_lock user can trigger inconsistencies. We found that
as this resulted in lockups and the O_DIRECT use case was just a reproducer that does
not need a kernel module.

  reply	other threads:[~2026-07-23 11:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <c6dfdac9fc51c94183e51a861eec269185239660.1784787211.git.wqu@suse.com>
2026-07-23  6:48 ` [PATCH RFC v2] btrfs: disable direct reads to avoid dirty folios without fs knowing Christian Borntraeger
2026-07-23  6:59   ` Qu Wenruo
2026-07-23  9:45     ` Help needed to address the dirty folio without fs notification delimma (Re: [PATCH RFC v2] btrfs: disable direct reads to avoid dirty folios without fs knowing) Qu Wenruo
2026-07-23 12:37       ` Matthew Wilcox
2026-07-23 10:38 ` [PATCH RFC v2] btrfs: disable direct reads to avoid dirty folios without fs knowing Filipe Manana
2026-07-23 11:17   ` Qu Wenruo
2026-07-23 11:23     ` Filipe Manana
2026-07-23 11:45       ` Christian Borntraeger [this message]
2026-07-23 11:31 ` 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=be2eff36-fbff-4451-9a63-84f95968370c@linux.ibm.com \
    --to=borntraeger@linux.ibm.com \
    --cc=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=quwenruo.btrfs@gmx.com \
    --cc=wqu@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