Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp143565rdb; Wed, 14 Feb 2024 16:02:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXO2scrfqKtr1mJnQ4Qhqv9h/hMsl9I2JtJx0cStY40dNnW7tTm5QdWj0J87DExlFcBJIw3aYSkgDB0kckARsAV6IoqRtB+DXYBZGtkdw== X-Google-Smtp-Source: AGHT+IH82PGgdPj28f/k1eA0ptQOtBk1mD4q1gKB1sQ8/mfFCFhxaXsMDKAGsZOHYEbigZuGU+te X-Received: by 2002:a05:620a:2019:b0:787:3315:5362 with SMTP id c25-20020a05620a201900b0078733155362mr362733qka.43.1707955350539; Wed, 14 Feb 2024 16:02:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707955350; cv=pass; d=google.com; s=arc-20160816; b=v7Jk5U5KlroqS1A34eRg05gbEvjE2zeDpZZQD0ef/mFPX3i81WTGVLDyWxU/s8F3c9 tqp0NQZquvgW1e0BbYBsoDzzr0NKjYtjfPPoAW5I6VN38LmDsPnTTJKOgk+CZk38Tmmd ExjO0lvq9ro5VqHoDuxVYqD9qtnEUAYGirIvOVif85YOKZY+tsX9VEp07LqyCfhVYm4f /eBRONDV/ayTyEDu3qiWAOiczXKh94Vo7tw3ylclaV5gLX7NUDIjsswiwx1MaOwWXRam glw7dj0u2sG09gBh4iYTwm+u5y+HWr/NsoUdLhPjP6fi6LAt7GM8Wp7PZc252O5h3mJd YU1g== 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=2FtKj2f173uLLcCNY9A9PsE2MP3SioixZxSyEQNKXd8=; fh=2iydB5pt4SYT/kH4TIHHSsSMF4WO/iWQt5Wj30+i5ig=; b=ldmnDnmFxP2TQ15HNj+JfHaFiRbjhh1fq0okKIpRctDPFBiWyhKF5QGxfBY9tGFbrQ iDuoHNAF/1DEVnZhBX9nNJbtmFxZ9BdLWq3Sh80yTpxEN3RQ6EF59ufWxJ+hDT73+941 Eyx2wFnf6h9HhMwKUoD81W2ZbZnrjJ7XN2rJd11nXGK0k0T3H+TQjOAthCH4tDCo6JJn N5KW4wK6RnqJ2cW8XhtI95SRwuUjVmNg8GCp8SLKp/tpmcyfeP5e/0j8YxK9iL57mD66 Pbet2ocnRqFq+dRQeOxhelUYzGayZ5OUgyrQ595Fas3htLnjaVtk1fW+4SrnF4OseDAS mtlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZVSOA2rj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q3-20020a05620a038300b00785d5fd03a9si271840qkm.93.2024.02.14.16.02.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 16:02:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZVSOA2rj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-ext4+bounces-1233-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1233-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3BCE11C20CA9 for ; Thu, 15 Feb 2024 00:02:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4B69146003; Wed, 14 Feb 2024 23:59:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZVSOA2rj" 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 5A7B81420C4; Wed, 14 Feb 2024 23:59:06 +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=1707955147; cv=none; b=fOqEEu8ktKJ1EVIz+3vH/HNXNgbVLogodtGMvCA2FzIR4wwx0w40Qz8dOOfDWzmUIS8MiC2J988GerMFcdGqTgcCCskI9LtJDCHdAuHhh4QNlwpcMpaTQZt3MlSd3E3DrobqbZxlrpIEl4mSidxBzYZeLUIMXoSzvu521mMEEbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707955147; c=relaxed/simple; bh=BKcXm1qqYWOlTZyU6bx2ZkL1Mu0/Nbno89RNGSj8xP8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gBbNnjudK/Xisisk2DrEScW6EzIJsIg7Jckjox1vfSclEGFNeRPzK/hKCFU09fzacQNzNBC0H8TpkXtcvPv/M5FOqZ/Ly0wP7l78xwZULMzfw7WE9vyxuKTIj3Xl/LZCkw5e7DLIqwRN/3aQVPC6PnqtFs0NHjBaK6i1tkq8KTI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZVSOA2rj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 764D3C433C7; Wed, 14 Feb 2024 23:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707955146; bh=BKcXm1qqYWOlTZyU6bx2ZkL1Mu0/Nbno89RNGSj8xP8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZVSOA2rjzKIzPjyfuF+bMP9xI0wX2KW+oRcezoVimBGVPqX1z6gkl2czYeYhp9Qa+ qg28wTTSHzAhkJoOHB3uP0x5vjFujAfhUcTnpMiZVl3WwKZpLQNfqH4ydu8VIUBQVk 9iUYBFJVIbKv9qCLNVFjz2WwwX0GlggjnOxhoMjV9QhkpmTVch+/MEPiwmt3O+UOAp eObkOz8M6OadXl6RqzkcrD8XSAgXBEsiCYdGq6uqfby2sVSeOUQv5OJEHFsHaiho11 o3wvgs5SSdtTApXmat27ugEcHl63Nzf+wUkXRYx8CdHCwQxrs+m2QyRwfMuZYCrkOT MGzUHWqcRIyKg== Date: Wed, 14 Feb 2024 15:59:04 -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 03/10] fscrypt: Drop d_revalidate for valid dentries during lookup Message-ID: <20240214235904.GH1638@sol.localdomain> References: <20240213021321.1804-1-krisman@suse.de> <20240213021321.1804-4-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-4-krisman@suse.de> On Mon, Feb 12, 2024 at 09:13:14PM -0500, Gabriel Krisman Bertazi wrote: > Finally, we need to clean the dentry->flags even for unencrypted > dentries, so the ->d_lock might be acquired even for them. In order to might => must? > diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h > index 47567a6a4f9d..d1f17b90c30f 100644 > --- a/include/linux/fscrypt.h > +++ b/include/linux/fscrypt.h > @@ -951,10 +951,29 @@ static inline int fscrypt_prepare_rename(struct inode *old_dir, > static inline void fscrypt_prepare_dentry(struct dentry *dentry, > bool is_nokey_name) > { > + /* > + * This code tries to only take ->d_lock when necessary to write > + * to ->d_flags. We shouldn't be peeking on d_flags for > + * DCACHE_OP_REVALIDATE unlocked, but in the unlikely case > + * there is a race, the worst it can happen is that we fail to > + * unset DCACHE_OP_REVALIDATE and pay the cost of an extra > + * d_revalidate. > + */ > if (is_nokey_name) { > spin_lock(&dentry->d_lock); > dentry->d_flags |= DCACHE_NOKEY_NAME; > spin_unlock(&dentry->d_lock); > + } else if (dentry->d_flags & DCACHE_OP_REVALIDATE && > + dentry->d_op->d_revalidate == fscrypt_d_revalidate) { > + /* > + * Unencrypted dentries and encrypted dentries where the > + * key is available are always valid from fscrypt > + * perspective. Avoid the cost of calling > + * fscrypt_d_revalidate unnecessarily. > + */ > + spin_lock(&dentry->d_lock); > + dentry->d_flags &= ~DCACHE_OP_REVALIDATE; > + spin_unlock(&dentry->d_lock); > } > } Does this all get optimized out when !CONFIG_FS_ENCRYPTION? As-is, I don't think the d_revalidate part will be optimized out. You may need to create a !CONFIG_FS_ENCRYPTION stub explicitly. - Eric