Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5655847rdb; Wed, 13 Dec 2023 15:41:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8RqtJy0zmsVs0qM0yMBR1Z8RSafJSIpNuc6Wmt1qb0wVtKJwd26PlZ/QLGLsxyA9TVpa8 X-Received: by 2002:a05:6871:8a9:b0:203:14d8:2b12 with SMTP id r41-20020a05687108a900b0020314d82b12mr3123728oaq.76.1702510888190; Wed, 13 Dec 2023 15:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702510888; cv=none; d=google.com; s=arc-20160816; b=Oo46g26SyMwQat7JzT0rkd6Vu1dlWRRP2kepr3EFz+ZNp86NfDn1a/8R+oPdn/zX23 KPjpkyNSFIxx+2S3UWHqLT7vHqynRFqCKQ0iBuqYbvtbGbP3QldIcJxlJkx+rFzdVHGG Lywv9rPuqlE5m0L8dOdBGCObf5v/MvQVXJf+VjSr8CkbPPyx4LRsNsYyitXPepFNwGwM 9WIZXkitTCTyTHvmdX2itHRGHTwlG6vT8DO6OcgvUYVSkI8ikZ86OZIIwj1eeugx2M7O rZfRoTgHHOSw6cz+aNDoMy0r+qCh3VKeMu+0q8IWywxZ6WcoQptL8eVri2mYR6DdQUWE y+wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=wFdpRL19Qo72V5iD16rSLzA5DXdY7+DFwh/2hlpfLqI=; fh=UEin7YZ4eM5mX713C41+LGZX7Kx6awDGobYQnpIpl5Y=; b=KaxRYN4DjzIlzeWY3PGoWN9xYH/eWmAikeL/dELaSz62sPrbmdCCfldiC6hoyDdwfV 5Fa7yRKk5By1XhYZzTg/3Th1WlS60C/gIQkRJtNGCSNydpjtE3uT9QoTukiwFb2tMf7V VrNhi1s6elIATaejyFWsu1QKjCRHflQdA1VfmUzksOACL7gesbABir02Q1ognJ98+o8x 7Ta0SvGMqAwzynkJMhtWr9YlDBoaDFheq8bnYS1Yt/vaZvH+WNHH5N4EA4nDrAHheb6Z NyGltEh2t7wTuxD1DhFTLWlyetR7d8Zl2OQwZRbWnokX5Hr5YTpB/PFSS9YTA7AQ8Zhc szIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4+bounces-434-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s15-20020a63214f000000b005c219360d9csi10331686pgm.50.2023.12.13.15.41.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:41:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-434-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; spf=pass (google.com: domain of linux-ext4+bounces-434-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-434-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de 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 CBF5A280994 for ; Wed, 13 Dec 2023 23:41:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5E1883B00; Wed, 13 Dec 2023 23:41:17 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1378B19B3; Wed, 13 Dec 2023 15:40:45 -0800 (PST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D089822310; Wed, 13 Dec 2023 23:40:42 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8D7FA1377F; Wed, 13 Dec 2023 23:40:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 44ZFG/pAemVlPgAAD6G6ig (envelope-from ); Wed, 13 Dec 2023 23:40:42 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH 2/8] fscrypt: Drop d_revalidate if key is available Date: Wed, 13 Dec 2023 18:40:25 -0500 Message-ID: <20231213234031.1081-3-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213234031.1081-1-krisman@suse.de> References: <20231213234031.1081-1-krisman@suse.de> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: X-Spam-Score: -4.00 X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: D089822310 X-Spam-Flag: NO fscrypt dentries are always valid once the key is available. Since the key cannot be removed without evicting the dentry, we don't need to keep retrying to revalidate it. Signed-off-by: Gabriel Krisman Bertazi --- fs/crypto/fname.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index 7b3fc189593a..0457ba2d7d76 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -591,8 +591,15 @@ int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) * reverting to no-key names without evicting the directory's inode * -- which implies eviction of the dentries in the directory. */ - if (!(dentry->d_flags & DCACHE_NOKEY_NAME)) + if (!(dentry->d_flags & DCACHE_NOKEY_NAME)) { + /* + * If fscrypt is the only feature requiring + * revalidation for this dentry, we can just disable it. + */ + if (dentry->d_op->d_revalidate == &fscrypt_d_revalidate) + d_set_always_valid(dentry); return 1; + } /* * No-key name; valid if the directory's key is still unavailable. -- 2.43.0