Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp567875pxj; Fri, 11 Jun 2021 06:14:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWOf7HE8w3CRTYVbERbk/Llem6iA6GmsBvVT8EdkUzp9kE0HK31wpIDVWOrtxvXb/ur6lQ X-Received: by 2002:aa7:c354:: with SMTP id j20mr3648511edr.294.1623417255368; Fri, 11 Jun 2021 06:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623417255; cv=none; d=google.com; s=arc-20160816; b=lGJUEVaGm6X2jLMFOopBowj+r93Ab+3MiUANVo/x4NaHd59MTx/E4Kb0VMeUjMdYJt v87GMmehpTiM9vjUQ75Y9viYghHg6ovk3Me57vZNbMJTj9T5iX5pXJVMpAY6Vsarf1Nu 9h2rCd2+9r3Jup0m68uCd8oG6+a34H7lFQlk75Y15kJJQWEWIFSuZ734X9DU2qEjDDX/ nhPmzkHsiZbPv+zZelynoPkGzwr9pCYeQPXCR8bck2Y+faT4IZRvKQbJyXtOnYKxioFl CuT8SBEtm53LNP40HC/2EUJQBrW0nPpwwQHuORXNQRDtgz2ZmJwELICqGRw3jl44KACT u7ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=G2mQncfrs7AfFiUrkmQW6cIH8U36siV+Y7SfstDBq4I=; b=FF08mp22UwxF7Xf+gkbMz3BwWazxPFtZYkywAIdYWWQt+Vd6X+ov3OcMW74Y8WRoy4 KrYUgC1f+iYWQqnoUvX2iW2S86JCyaJ0ZptKmmmMJJ32MElCNrwzl1OQ6I/uzUJoL4bL GJ+g/f8QTc1grgnivCxLif9kd5jxR83vaQGuU/CxHDMzi/ShXv32OXbghwouw9MQMdsC 6TH7//AIGTq/iGICvekP+yWVOTbmgN24eoKQu5wE/MQBvPxSTpuwz6fZzpyctNRzZrKF MeYnHxATLtQ9mrFSJhJWX2c6B/qDpX/AiW6iRgMdFnJoQVT7g7pIujSidzWuw0ESLgMb KRTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=YzjcMGP3; 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 dm9si4713623edb.350.2021.06.11.06.13.50; Fri, 11 Jun 2021 06:14:15 -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=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=YzjcMGP3; 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 S231800AbhFKNN6 (ORCPT + 99 others); Fri, 11 Jun 2021 09:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231795AbhFKNN6 (ORCPT ); Fri, 11 Jun 2021 09:13:58 -0400 Received: from mail-vs1-xe2d.google.com (mail-vs1-xe2d.google.com [IPv6:2607:f8b0:4864:20::e2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D782AC0617AF for ; Fri, 11 Jun 2021 06:11:59 -0700 (PDT) Received: by mail-vs1-xe2d.google.com with SMTP id 68so3712955vsu.6 for ; Fri, 11 Jun 2021 06:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G2mQncfrs7AfFiUrkmQW6cIH8U36siV+Y7SfstDBq4I=; b=YzjcMGP3UQnO1hid52zVsZw/+JgVMd/sqhgVfs3xBOo3bzdZT1WGZorX2pxsstxlb3 iFVI7wbbEnZ1b/cR6Dw6q6JOZ6TcCe2M+4onbA89UQr39g/N1fQzaIDeGPDkcp98Unm0 CShXp+XTdvNwziAQdxfL58laQ18gC4Q30Z5p0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G2mQncfrs7AfFiUrkmQW6cIH8U36siV+Y7SfstDBq4I=; b=Y4v0e0sOWvtMtTvJx3s2NE92ZkzRsmh7yZ75VVuf5k2OuTvWcwBfXh9vIQBF883wfX BxT1CxtGVKiv1nRkpWuWO3krZg06gpSLDafAxcS/+rBSfqjhcFVTzI2Mv6UM3QIOqohI sjGT3kEKcNXBE3QRQ/eb8ZEBQ78hcQb1suzWbNtRikxKMHhJpW4ahnAiKH5VxQe/nckG BrEt6QMDP4axS4lkgsixS5g/DX75YENrDttIA7Fvx++k7egoDWDuGW37KLqdaJNAw5Vt SKaBasGlDoa/H8NLgOYf32r0G3qM/Gr2V2LxBhAJwAijfQ19CB4Q/1drvdB6N/uqkBTc KXHQ== X-Gm-Message-State: AOAM532FRgFHWuSOJJJ1731A1ErXzBkoGPxS3lXDaTsRSwPgvZsMJHIA RSYK2vmZ6kLR/cVVLrW2g7n2L+DLgCbQ46uGVUdGVw== X-Received: by 2002:a67:f659:: with SMTP id u25mr4911654vso.9.1623417119022; Fri, 11 Jun 2021 06:11:59 -0700 (PDT) MIME-Version: 1.0 References: <162322846765.361452.17051755721944717990.stgit@web.messagingengine.com> <162322868275.361452.17585267026652222121.stgit@web.messagingengine.com> In-Reply-To: <162322868275.361452.17585267026652222121.stgit@web.messagingengine.com> From: Miklos Szeredi Date: Fri, 11 Jun 2021 15:11:48 +0200 Message-ID: Subject: Re: [PATCH v6 5/7] kernfs: use i_lock to protect concurrent inode updates To: Ian Kent Cc: Greg Kroah-Hartman , Tejun Heo , Eric Sandeen , Fox Chen , Brice Goglin , Al Viro , Rick Lindsley , David Howells , Marcelo Tosatti , "Eric W. Biederman" , Carlos Maiolino , linux-fsdevel , Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Jun 2021 at 10:52, Ian Kent wrote: > > The inode operations .permission() and .getattr() use the kernfs node > write lock but all that's needed is to keep the rb tree stable while > updating the inode attributes as well as protecting the update itself > against concurrent changes. > > And .permission() is called frequently during path walks and can cause > quite a bit of contention between kernfs node operations and path > walks when the number of concurrent walks is high. > > To change kernfs_iop_getattr() and kernfs_iop_permission() to take > the rw sem read lock instead of the write lock an additional lock is > needed to protect against multiple processes concurrently updating > the inode attributes and link count in kernfs_refresh_inode(). > > The inode i_lock seems like the sensible thing to use to protect these > inode attribute updates so use it in kernfs_refresh_inode(). > > The last hunk in the patch, applied to kernfs_fill_super(), is possibly > not needed but taking the lock was present originally and I prefer to > continue to take it so the rb tree is held stable during the call to > kernfs_refresh_inode() made by kernfs_get_inode(). > > Signed-off-by: Ian Kent Reviewed-by: Miklos Szeredi