Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp3508470ybg; Sun, 7 Jun 2020 01:44:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS/U+dTWr+ArgnhVtvgWDd/aOpyYzq7R1QuwaNhNxObw1CMLKVg+1Z+/JRFTmBaz40L0P2 X-Received: by 2002:a17:906:7d91:: with SMTP id v17mr16563339ejo.463.1591519480902; Sun, 07 Jun 2020 01:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591519480; cv=none; d=google.com; s=arc-20160816; b=KmzPcxHFepFiEc2/X4Yo0rr6isiANPKDy8TLW9jW54Vo+YR59YcN6OjFeagC0naxqk F1NGK2mF70m+cwweK/X73DZ77dcyOWzHlSKVx7qon+oHo59BdcytIk5E48rq1InQ3y4e PeaTDklp6TgCTGuUQ9sInHqK9st7isGySJ+26/BxkYRYABRC8nQbYyu85275Bxpc/hcj Wbd5bz/jhbviytHtp+uMQUWSS6W/ZGDyiCLrEKE7wWOUDZWJdxTyWbaXfFzge/cx/7Z2 fjHrTRhsH2AL6nZc626DsKlTSVMqoLhI2RSJK366E59h1ccPYfhI7w+XRU7Xog0GUEoA y8Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature:dkim-signature; bh=LEdB9Bo5hxAS0lxQEDRgkwN6u4BWFSF7qj8zTu/DWjs=; b=nFQ1acHtC+QNuQHSr80XIS/rhU8hVLf9Ixutcb9Gac04n5mTJ3Z0Cx/Ar5Pd27eSh8 yJnibleCBEyCGeCzl+P0vKwfNwd3Pi0aLvi6wNiu0Lg+402hBUdR/wZ98V+CgzVuOBAi ohmIcd+NdOXflW3ub9tcbuLwvv3CG4gI99bU4JDoj7LohE+us+M/b9v4Gsk4HaWbZgUD M/Y/hVXZ/pZneJcQAkS0gyEBCc+s6GKsXg2UO5zXnM3lYhqQ9Uo8Q1AQm9T0m1tKd3DW SM8AdWfDBnddt6ZKHEkgmlNPvzl9F4s05727Uz92CjlkTQHLkUtB8poN5eWiMWyVnb8R hJ+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm3 header.b="0CJQJp/F"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="CK//fHRn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si7306003edl.171.2020.06.07.01.43.51; Sun, 07 Jun 2020 01:44:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm3 header.b="0CJQJp/F"; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="CK//fHRn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726439AbgFGIkp (ORCPT + 99 others); Sun, 7 Jun 2020 04:40:45 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:56273 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbgFGIko (ORCPT ); Sun, 7 Jun 2020 04:40:44 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 460045C00A9; Sun, 7 Jun 2020 04:40:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 07 Jun 2020 04:40:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h= message-id:subject:from:to:cc:date:in-reply-to:references :content-type:mime-version:content-transfer-encoding; s=fm3; bh= LEdB9Bo5hxAS0lxQEDRgkwN6u4BWFSF7qj8zTu/DWjs=; b=0CJQJp/F9XO0FSzM HoEgDzmwDAlTDgJCypTbAfBykPi7NCxAIK7l9rC3C9o3hAh02uZlQsce0Nw3+sqX IjqlDEXwBT2lm4hhhW5D89ZEoMXXkvxrLAI19jcUpFLbLQNyGm8CuCTl2h2raEBq s3oebkhq2YuiafZXyS4hPDz9F/K2vLODhngsh89nGn1W5TXS5jNu8VwIDugCKeBa FPvxoigJNs8XiWDOhU2tW/HvBFa7GxBkbwlgUhGGITMbuMaguzfDGFdbpJVeGUV7 cjLN2fCvKDsY84bjNh9bCBTvv0UuK1uPeEHsDoVg3I76RPHml8d0VU6Bz+xMiKES YEiNiA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=LEdB9Bo5hxAS0lxQEDRgkwN6u4BWFSF7qj8zTu/DW js=; b=CK//fHRnUtyzutf/dnr25BBM7kKSuEX3QTp3YsfcPDR3a13xwQaCceD0w dHahxYVa1uaZdVpM81J+XgNmpd1ZRHerq4rnFmQDfvZil3/60xgMChltn6p0BRKP S7swEmiAX+FKk1uv9FLRm2CyESB517nfNo1gIIYvS4vTLGuvm0sVdjLPu5n7dUqu Ec5ipRM0lH8NnjnNyciErH+F06pXLioe9xlnUA+/CeHAQxefG/dBhG8Y8jqriT31 cCSxM1SNK8m7HRruNYuW7AE5OgBqeUks4Xqq9KCCB7YCXgYBCrUzg+GbCm5bAn/s UtvuDlrngulIkN4oEWRL6gj/6VKdA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudegledgtdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkffuhffvffgjfhgtfggggfesthejredttderjeenucfhrhhomhepkfgrnhcu mfgvnhhtuceorhgrvhgvnhesthhhvghmrgifrdhnvghtqeenucggtffrrghtthgvrhhnpe effeettedvgeduvdevfeevfeettdffudduheeuiefhueevgfevheffledugefgjeenucfk phepheekrdejrddvvddtrdegjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehrrghvvghnsehthhgvmhgrfidrnhgvth X-ME-Proxy: Received: from mickey.themaw.net (58-7-220-47.dyn.iinet.net.au [58.7.220.47]) by mail.messagingengine.com (Postfix) with ESMTPA id 29791328005A; Sun, 7 Jun 2020 04:40:37 -0400 (EDT) Message-ID: <36e2d782d1aea1cfbe17f3bfee35f723f2f89c0d.camel@themaw.net> Subject: Re: [PATCH 1/4] kernfs: switch kernfs to use an rwsem From: Ian Kent To: Greg Kroah-Hartman Cc: Andrew Morton , l Viro , Greg Kroah-Hartman , Tejun Heo , Rick Lindsley , Stephen Rothwell , David Howells , Miklos Szeredi , linux-fsdevel , Kernel Mailing List Date: Sun, 07 Jun 2020 16:40:33 +0800 In-Reply-To: <159038562460.276051.5267555021380171295.stgit@mickey.themaw.net> References: <159038508228.276051.14042452586133971255.stgit@mickey.themaw.net> <159038562460.276051.5267555021380171295.stgit@mickey.themaw.net> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, On Mon, 2020-05-25 at 13:47 +0800, Ian Kent wrote: > @@ -189,9 +189,9 @@ int kernfs_iop_getattr(const struct path *path, > struct kstat *stat, > struct inode *inode = d_inode(path->dentry); > struct kernfs_node *kn = inode->i_private; > > - mutex_lock(&kernfs_mutex); > + down_read(&kernfs_rwsem); > kernfs_refresh_inode(kn, inode); > - mutex_unlock(&kernfs_mutex); > + up_read(&kernfs_rwsem); > > generic_fillattr(inode, stat); > return 0; > @@ -281,9 +281,9 @@ int kernfs_iop_permission(struct inode *inode, > int mask) > > kn = inode->i_private; > > - mutex_lock(&kernfs_mutex); > + down_read(&kernfs_rwsem); > kernfs_refresh_inode(kn, inode); > - mutex_unlock(&kernfs_mutex); > + up_read(&kernfs_rwsem); > > return generic_permission(inode, mask); > } I changed these from a write lock to a read lock late in the development. But kernfs_refresh_inode() modifies the inode so I think I should have taken the inode lock as well as taking the read lock. I'll look again but a second opinion (anyone) would be welcome. Ian