From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBE6BC433E2 for ; Thu, 18 Jun 2020 15:04:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 934D22075E for ; Thu, 18 Jun 2020 15:04:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="EuLHMlaV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 934D22075E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3B02D8D002C; Thu, 18 Jun 2020 11:04:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 360AC8D0018; Thu, 18 Jun 2020 11:04:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 277978D002C; Thu, 18 Jun 2020 11:04:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 0FDC58D0018 for ; Thu, 18 Jun 2020 11:04:33 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B90C118F0EE for ; Thu, 18 Jun 2020 15:04:32 +0000 (UTC) X-FDA: 76942653984.18.fang89_2003ce026e11 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 16B4A1019FF5D for ; Thu, 18 Jun 2020 15:04:01 +0000 (UTC) X-HE-Tag: fang89_2003ce026e11 X-Filterd-Recvd-Size: 4414 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 15:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=UL+8ApV4cJJsaL9i1XR4k0qibz3XspT8vONGVk524kc=; b=EuLHMlaVNrGT+gpgg4ZOy214Lf /NetdKt4msEGn/SdU6wS7Vb3Nicec9n/1E16Pv5CLgJpT25JAXyLZqTClcv5dthiCzHK32BiNFyNn 2Vtkj1cmYSbWiXKfh18xDTiF4w22UEYWsdQ5WG/abzsVteDtOAX8vWZ3bKmb0ydVHdoW/dmfLoAdv rcWXcFdBrgdT+0Rnct9YP5xWZ5E6pNPsBKwkf9wU8u6uAxjlRbX/tFeF4hooENdTFNAX/QSEm8LMc hZs29nl0IRtyQgR2KBWEayJ7IYD2dzdJAKDyw0r1yoEP6TVl666nT/5G8UpJw9LpuF0WelqGPXar4 ortJ5rhQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlw4L-0003On-LK; Thu, 18 Jun 2020 15:03:09 +0000 Date: Thu, 18 Jun 2020 08:03:09 -0700 From: Matthew Wilcox To: Andreas Gruenbacher Cc: Andreas =?iso-8859-1?Q?Gr=FCnbacher?= , Andrew Morton , linux-xfs , Junxiao Bi , William Kucharski , Joseph Qi , John Hubbard , LKML , linux-f2fs-devel@lists.sourceforge.net, cluster-devel , Linux-MM , ocfs2-devel@oss.oracle.com, linux-fsdevel , linux-ext4 , linux-erofs@lists.ozlabs.org, Christoph Hellwig , linux-btrfs@vger.kernel.org, Steven Whitehouse , Bob Peterson Subject: Re: [Cluster-devel] [PATCH v11 16/25] fs: Convert mpage_readpages to mpage_readahead Message-ID: <20200618150309.GP8681@bombadil.infradead.org> References: <20200414150233.24495-1-willy@infradead.org> <20200414150233.24495-17-willy@infradead.org> <20200617003216.GC8681@bombadil.infradead.org> <20200617022157.GF8681@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 16B4A1019FF5D X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jun 18, 2020 at 02:46:03PM +0200, Andreas Gruenbacher wrote: > On Wed, Jun 17, 2020 at 4:22 AM Matthew Wilcox wr= ote: > > On Wed, Jun 17, 2020 at 02:57:14AM +0200, Andreas Gr=FCnbacher wrote: > > > Right, the approach from the following thread might fix this: > > > > > > https://lore.kernel.org/linux-fsdevel/20191122235324.17245-1-agruen= ba@redhat.com/T/#t > > > > In general, I think this is a sound approach. > > > > Specifically, I think FAULT_FLAG_CACHED can go away. map_pages() > > will bring in the pages which are in the page cache, so when we get t= o > > gfs2_fault(), we know there's a reason to acquire the glock. >=20 > We'd still be grabbing a glock while holding a dependent page lock. > Another process could be holding the glock and could try to grab the > same page lock (i.e., a concurrent writer), leading to the same kind > of deadlock. What I'm saying is that gfs2_fault should just be: +static vm_fault_t gfs2_fault(struct vm_fault *vmf) +{ + struct inode *inode =3D file_inode(vmf->vma->vm_file); + struct gfs2_inode *ip =3D GFS2_I(inode); + struct gfs2_holder gh; + vm_fault_t ret; + int err; + + gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &gh); + err =3D gfs2_glock_nq(&gh); + if (err) { + ret =3D block_page_mkwrite_return(err); + goto out_uninit; + } + ret =3D filemap_fault(vmf); + gfs2_glock_dq(&gh); +out_uninit: + gfs2_holder_uninit(&gh); + return ret; +} because by the time gfs2_fault() is called, map_pages() has already been called and has failed to insert the necessary page, so we should just acquire the glock now instead of trying again to look for the page in the page cache.