Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Pedro Falcato <pfalcato@suse.de>, Brahmajit Das <listout@listout.xyz>
Cc: dsterba@suse.com, linux-btrfs@vger.kernel.org, clm@fb.com,
	mason@kernel.org, david@kernel.org, jgg@ziepe.ca,
	jhubbard@nvidia.com, peterx@redhat.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
	Brahmajit Das <bdas@suse.de>,
	syzbot+d6f123d4060990f0f3ff@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] btrfs: re-attach folio private when a released folio gets dirtied
Date: Fri, 4 Dec 2026 07:13:08 +1030	[thread overview]
Message-ID: <aadde5b8-a825-4046-99fc-985bb1d76511@suse.com> (raw)
In-Reply-To: <axFtfUuAluTAYLb_@pedro-suse.tail5790ac.ts.net>



在 2026/12/3 23:58, Pedro Falcato 写道:
[...]
>> When the read completes, the folio is re-dirtied without notifying the
>> fs:
>>
>>    bio_release_pages()
>>      folio_mark_dirty()
>>        btrfs_data_dirty_folio()
>>          filemap_dirty_folio()
> 
> FWIW, this sounds like a variant of
> https://lore.kernel.org/linux-mm/20261119-gup-dirty-what-v1-0-236d69f25c24@suse.de/.
> (which I will respin soon)

One assumption doesn't meet the current code.

 >  - ->dirty_folio() relies on buffers/IFS/etc being attached to the
 >   folios. It _cannot_ attach them itself, as dirty_folio() cannot
 >   block.

Iomap is already attaching it:

iomap_dirty_folio()
   ifs_alloc(inode, folio, 0);
     gfp = GFP_NOFS | __GFP_NOFAIL;
     ifs = kzalloc_flex(..., gfp);

Either it's already a bug, or we won't hit such folio without private 
for the non-sleeping routes.

> 
>>
>> If the folio is beyond EOF by then, btrfs_data_dirty_folio() does not
>> touch any btrfs state, and the next writeback calls folio_invalidate()
>> on a folio without private, triggering the above ASSERT() in the
> 
> ? why is writeback calling folio_invalidate()?

If a folio is beyond EOF, we have no need to write it, thus can go 
invalidating it directly.

Or is there any better solution from the perspective of MM?

Thanks,
Qu

> 
>> bs < folio size case.  If the folio straddles EOF,
>> btrfs_folio_set_fixup_dirty() dereferences the NULL folio private
>> instead.
>>
>> Fix it by re-attaching the folio private in btrfs_data_dirty_folio()
>> if it is missing.  ->dirty_folio() may not block, so use GFP_NOWAIT.
> 
> NAK to this approach. I need to think about folio_invalidate() and its
> interaction with GUP a little harder.
> 



  reply	other threads:[~2026-12-03 20:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  4:18 [PATCH v2] btrfs: re-attach folio private when a released folio gets dirtied Brahmajit Das
2026-12-03  4:19 ` sashiko-bot
2026-12-03 13:28 ` Pedro Falcato
2026-12-03 20:43   ` Qu Wenruo [this message]
2026-12-04 10:05     ` Pedro Falcato
2026-12-04 12:48       ` Brahmajit Das
2026-12-04 21:05       ` Qu Wenruo
  -- strict thread matches above, loose matches on Subject: below --
2026-12-02  4:11 Brahmajit Das
2026-12-03  4:11 ` sashiko-bot
2026-12-02  4:08 Brahmajit Das
2026-12-02  5:51 ` sashiko-bot
2026-12-02  7:17   ` Qu Wenruo

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=aadde5b8-a825-4046-99fc-985bb1d76511@suse.com \
    --to=wqu@suse.com \
    --cc=bdas@suse.de \
    --cc=clm@fb.com \
    --cc=david@kernel.org \
    --cc=dsterba@suse.com \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=listout@listout.xyz \
    --cc=mason@kernel.org \
    --cc=peterx@redhat.com \
    --cc=pfalcato@suse.de \
    --cc=syzbot+d6f123d4060990f0f3ff@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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