From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6191348866 for ; Mon, 8 Jun 2026 12:19:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780921176; cv=none; b=OoTFUihIGsazD3096OpiaC1hSKj9uTIoMP3pr+E72bmbjVSDuiKiuRsW6FGnalwLENBAIE+KwKkT5pr+eMR5oC3YFBSUZKij/jw9776T6RqkFyORDGScphMcMxvTX+0nM3pxA3VeXYhuyvwYyOjCyG4FTcqHuizfzFwB9ze3kv4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780921176; c=relaxed/simple; bh=Gm52JC1pxfY6oFn4titjSLr3mKhUMDPTS1BaM0Itark=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nXeQT77N3SZDcsM9wQDd7weEIq6QbWF8YzAg+/2eHDtbjgheI4BAIXqiPE//+4VuZWtPO6XH15mT8e/2ht+hl0vnWM5aR7e21dhzpdQRXIzuQ38XFyU5VFrpg2YCkr0aC3FLLd8wBLysHZIszoc0XJhe+cDmj2VbRWsF3oHgiSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=pK+Z52VA; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="pK+Z52VA" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qERTLKCFsdtVE8IpdID0EeMDJispzoTVRSNdOHDPl+k=; b=pK+Z52VAGK7KZAkOuITnxC5Vb3 PHYL5/DgnXPAXjaENesapBN3zjmkmz57XsRw8+bJY+htyOPt5FpciVJww09WW4VYADB/o3pCPBa+o ITQzIAQxDQ6ajm9AiQLxeRKpk0ymSQm4RiFaCgEFylJdFsDx8wn0vu3aBBMFnoVGUiAeyyFdMVAWx c8DQPYwUDeUtlb8qJqAsFHk64VN+7v1Ku70v/bxaYv3Gm8zHr0rAhg5D9VIF/bbpoDy1u+F8LVNCf 6dJeaZUFkrrUe7jJTISR/DA18ypFmeTq1siCNdf7QqN1ucOHV34oQQ79CnsjJwfMC2XVZnkKbKRxh vh8bnBjQ==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wWYx0-0000000DffW-0nlk; Mon, 08 Jun 2026 12:19:30 +0000 Date: Mon, 8 Jun 2026 13:19:30 +0100 From: Matthew Wilcox To: Dev Jain Cc: Jan Kara , "linux-mm@kvack.org" , David Hildenbrand , Ryan Roberts , LKML Subject: Re: [BUG?] invalidate_lock not held in read_cache_folio() Message-ID: References: <5ca6512c-bdc1-4620-9c99-c7525e059099@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ca6512c-bdc1-4620-9c99-c7525e059099@arm.com> 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