Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp150717rdb; Wed, 14 Feb 2024 16:16:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXV0RRy0fmaOWrqO7sbBdPaVjhVeBGp5nDh0+kWRLvGoyNqnS/acvaOk9qdn3YWkPANgcux87XBu78zKFJ91cYkc1W+dUFO9Du1kI5Ksw== X-Google-Smtp-Source: AGHT+IHZ4dFLCOgVbWwOX+nOgfGQh2msfH8LpErlElTCB7Keq1HQt1yWLT3/WWs5Vdr/F5AuBdZ3 X-Received: by 2002:a17:902:e551:b0:1d9:bff2:67d3 with SMTP id n17-20020a170902e55100b001d9bff267d3mr316061plf.0.1707956201321; Wed, 14 Feb 2024 16:16:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707956201; cv=pass; d=google.com; s=arc-20160816; b=L7TSp5EZgW3nObdJzR9S8QxT6u7DCpYELv9hY1/uqwQ63F4zuyOHsoTH4VvrlCsDrB jtw4JrC0U+NEGqVVUYKxy5PGnMmAt/TRVLYjV5fW/AT9/TTMsyxfgiYjQE0UolRKomCk 0VUqYFfvHe+mXJ1Jh2q9/Q7lDKSsX13OxxGfpcOE9zUUrKrkKfFrc74gJ/c3xBZj9sr7 VOi4vGZJXjQXr0wai90GtZo2DomZKUVUHafxX8Z1FmvSn/oFaKyy0ljuch3Vc1c77XeP Mhh8cAjORgz/Uap6lIrXjDR5SMtdXInuy3xR9Edfod8/vs/S6j/da81bgP6pu4Tcvtrz K45A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=5mOwL+EGIOBx/xim2ZXhrn61+VNM/cAXORgsz1BYVJQ=; fh=2iydB5pt4SYT/kH4TIHHSsSMF4WO/iWQt5Wj30+i5ig=; b=frtLTMcKnWvM+nbWg4P+BD1cRrTfIZ6YIQj2c17WdFgcagOlHkPyBkuc7Ft4aXty3L jT0ZK2FKnTa0x8JqkM+uQ3ZzKTvbQta6oE9IIS/15W5knM5QEzHFQgRqgHUzOIXSmCA8 Y/2KNQd9Va9GIT2CQjA1QLoQvMJEnPYN5o9a+xbpnIhShhFdk3GfFDnbQ3bx3ARETPbQ 0p5xjCXEm+j26kCAhWHZ1pbq4/PhzOkcgWmXhY7qpyBZ+NrbaCBlRkrDgbttD/IuOBAJ SFB79eBcbUcXkaejRDTR3AS0XthF0nkOBTKUJhB26LHhaY8GBp5+2N83uf5OvAU0GXKy sFuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VEvdwyv9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-1234-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 18-20020a170902ee5200b001db50738493si51963plo.232.2024.02.14.16.16.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 16:16:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1234-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VEvdwyv9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-1234-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1234-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B97E7284805 for ; Thu, 15 Feb 2024 00:16:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC94A803; Thu, 15 Feb 2024 00:16:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VEvdwyv9" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 500AB389; Thu, 15 Feb 2024 00:16:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707956194; cv=none; b=Cx52DQalSS/w91UeZ/DOi8HpS8qlnTwaRvfRwopvdB0fFwoltNIdouWGorNXv3uB1qEEEIEZRVHd9Snjsi/KWV0cx8WWxJZCQkjjiTOahaGhEmvfFFlLlLe4enl8GjcQi5WFpc64ZOR6E1yKSIFTeUbZJ6YnoFSLykAdEPwQkUk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707956194; c=relaxed/simple; bh=ylFK6Bpi7O0s6j/9+mo/NrShh6U5P03/xrJn/rG4PpM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fGee5vCyTlFk/kkm3jR1JE+k8hED3L2gRUAPef+OB0z40J/46gYWlok8arAlGSksd7aSajUL/I7rNOwoDZ8rXpzd9KZYLE4/Dvdc1mTTOa0QI7IUqYEouKnfow2c82aapcjCqLjf0SbK2M0P0+8Q2DXlj6GFrumxMt1rjSq1xKY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VEvdwyv9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CCF9C433F1; Thu, 15 Feb 2024 00:16:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707956193; bh=ylFK6Bpi7O0s6j/9+mo/NrShh6U5P03/xrJn/rG4PpM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VEvdwyv92kXe4udUPiYfbfA9b6N6wY5f05UN/tXpwXHit2VxdlHZZIQ4lvbl7JCb6 fGYXD6oQSJ9SpdC361S/r4aUdmN4cyBhjtlCshylY1BOlBXnmc+mg7N+1s0hBW3kTz pIt0vbs66fOB1cWPiOnO1k/uVsWavea+HZjzPACrazcYPZSV+EvqjVs309elxkHM2A Z2qgQmP6d1NRO6s+/qrBmK+BA6yW/WOrypcYy7gygv260aFM2OVif9hW82XZub3Uhc DXBqhfAWjEU4KDEIHfzixirflHkeiWRiORgDXBCdku4/cEfJ/9n9YdZPUNTe4MlRSh G2KeHLq9+gT8w== Date: Wed, 14 Feb 2024 16:16:31 -0800 From: Eric Biggers To: Gabriel Krisman Bertazi Cc: viro@zeniv.linux.org.uk, jaegeuk@kernel.org, tytso@mit.edu, amir73il@gmail.com, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, brauner@kernel.org Subject: Re: [PATCH v6 04/10] fscrypt: Drop d_revalidate once the key is added Message-ID: <20240215001631.GI1638@sol.localdomain> References: <20240213021321.1804-1-krisman@suse.de> <20240213021321.1804-5-krisman@suse.de> Precedence: bulk X-Mailing-List: linux-ext4@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: <20240213021321.1804-5-krisman@suse.de> On Mon, Feb 12, 2024 at 09:13:15PM -0500, Gabriel Krisman Bertazi wrote: > From fscrypt perspective, once the key is available, the dentry will > remain valid until evicted for other reasons, since keyed dentries don't > require revalidation and, if the key is removed, the dentry is > forcefully evicted. Therefore, we don't need to keep revalidating them > repeatedly. > > Obviously, we can only do this if fscrypt is the only thing requiring > revalidation for a dentry. For this reason, we only disable > d_revalidate if the .d_revalidate hook is fscrypt_d_revalidate itself. > > It is safe to do it here because when moving the dentry to the > plain-text version, we are holding the d_lock. We might race with a > concurrent RCU lookup but this is harmless because, at worst, we will > get an extra d_revalidate on the keyed dentry, which is will find the > dentry is valid. > > Finally, now that we do more than just clear the DCACHE_NOKEY_NAME in > fscrypt_handle_d_move, skip it entirely for plaintext dentries, to avoid > extra costs. > > Signed-off-by: Gabriel Krisman Bertazi I think this explanation misses an important point, which is that it's only *directories* where a no-key dentry can become the regular dentry. The VFS does the move because it only allows one dentry to exist per directory. For nondirectories, the dentries don't get reused and this patch is irrelevant. (Of course, there's no point in making fscrypt_handle_d_move() check whether the dentry is a directory, since checking DCACHE_NOKEY_NAME is sufficient.) The diff itself looks good -- thanks. - Eric