From: Matthew Wilcox <willy@infradead.org>
To: Dev Jain <dev.jain@arm.com>
Cc: Jan Kara <jack@suse.cz>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
David Hildenbrand <david@redhat.com>,
Ryan Roberts <ryan.roberts@arm.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [BUG?] invalidate_lock not held in read_cache_folio()
Date: Mon, 8 Jun 2026 15:02:21 +0100 [thread overview]
Message-ID: <aibLbSANZh6ijw-h@casper.infradead.org> (raw)
In-Reply-To: <903740a1-d48d-458e-8fa3-c129c68b5390@arm.com>
On Mon, Jun 08, 2026 at 06:59:46PM +0530, Dev Jain wrote:
>
>
> On 08/06/26 5:49 pm, Matthew Wilcox wrote:
> > On Mon, Jun 08, 2026 at 04:54:51PM +0530, Dev Jain wrote:
> >> Hi,
> >>
> >> My understanding is that there are two ways we are serializing against concurrent
> >> addition of a folio into the pagecache (see 730633f0b7f9).
> >>
> >> The kerneldoc of read_cache_folio() says:
> >>
> >> "Context: May sleep. Expects mapping->invalidate_lock to be held."
> >>
> >> I put the following in __filemap_add_folio():
> >>
> >> + BUG_ON(!inode_is_locked(mapping->host) &&
> >> + !rwsem_is_locked(&mapping->invalidate_lock));
> >>
> >>
> >> And got the following trace:
> >>
> >>
> >> [ 0.115587] Call trace:
> >> [ 0.115686] __filemap_add_folio+0x5dc/0x680 (P)
> >> [ 0.115871] filemap_add_folio+0xec/0x2d0
> >> [ 0.116031] do_read_cache_folio+0x144/0x2d8
> >> [ 0.116194] read_cache_folio+0x1c/0x30
> >> [ 0.116344] read_part_sector+0x4c/0xf0
> >> [ 0.116499] read_lba+0xb0/0x1a0
> >> [ 0.116627] efi_partition+0xa8/0x740
> >> [ 0.116769] bdev_disk_changed+0x238/0x620
> >> [ 0.116939] blkdev_get_whole+0xac/0x100
> >> [ 0.117090] bdev_open+0x280/0x3c0
> >
> > You can't truncate or holepunch a bdev
>
> Yep, I realized that later, thanks : )
>
> Just that the kerneldoc says "Expects mapping->invalidate_lock to be held"
> so was wondering whether this comment is appropriate. Difficult for me to
> reason about that since this goes into fs/block code.
Yes, you've found a documentation bug.
+ BUG_ON(!inode_is_locked(mapping->host) &&
+ !rwsem_is_locked(&mapping->invalidate_lock) &&
+ !S_ISBLK(mapping->host->i_mode));
might do what you're looking for?
next prev parent reply other threads:[~2026-06-08 14:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 11:24 Dev Jain
2026-06-08 12:19 ` Matthew Wilcox
2026-06-08 13:29 ` Dev Jain
2026-06-08 14:02 ` Matthew Wilcox [this message]
2026-06-09 11:58 ` Jan Kara
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=aibLbSANZh6ijw-h@casper.infradead.org \
--to=willy@infradead.org \
--cc=david@redhat.com \
--cc=dev.jain@arm.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryan.roberts@arm.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
all inboxes | Powered by JetHome®