Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp624864rdb; Mon, 29 Jan 2024 12:44:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IFy76OfuAHpZ/hR0/qzqXg7T8q2oM5P30UlcV/TUGQmWT5VdFkoxQ7YfqVxHn/ctk+ct3NX X-Received: by 2002:a05:6402:1763:b0:55e:f31c:378 with SMTP id da3-20020a056402176300b0055ef31c0378mr2875995edb.13.1706561072061; Mon, 29 Jan 2024 12:44:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706561072; cv=pass; d=google.com; s=arc-20160816; b=0ZUFoLVu41vkUA16cTjvmanYppH6x260emGnrOQv8AsvXrPY4x9bcF+qeF0ODQRsmv YyB4iMia1sxYIBNnF61Xu/dl7cWxz6hH0NVst4f8QYZL17nYsEi/Xzh4XH0jzlhUZCnQ rwgowbBX5Nb/GTrbWBh50tQwFKh6L1eS4BIZLfnFAQFT2VtqApHCT0bqUeXL//1Urwpi n1l6WaTG5n0QGWhrt9go2ubxOPOjzvALc9bWu4XfUfEMTiR1weu+ReTQtpbPvJyUglmA 1lIT0QjLb9RW+wG5MRL4uYefZsWAggj2PgDSRuwdYbgh/xeDDWhjUJVSFReRTTJqR7dJ Uw/A== ARC-Message-Signature: i=2; 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=unr8RrcAXNAzuXvEUPC3o496QlxhkRxYikViGY3ZEUA=; fh=M648oune0DwZmCHpgeKmdqyNG9Pnhrh1APj5VeeCjyQ=; b=DVnaj+pwWCYnYPM5RBvrzX1W9GdNqR0l+Jw5saTARU62HQpYSSPKDxSQTRcCPRamyd VqAbgNiy8WSnydgk9zfFILDwKxa2/kkKR4eKULN4e3hf0I2mYACFivkikjR/HwccD5mq 31x6zL3YN7I3/niLMVgsFilxbNpJCDxwd2Bk1cl46doz1TsGwEYdV1bzFrJDDLAnSxZj MfBuO55YJuhg88IwPv7Ly2dyNh1aVL8HcKaZJ4P3zmuUVTfcECAKG/AJsh/rnN0tDsa8 3UFRPw5YGuq2S8mTo9Bp++4vuSRpNBSRsAd7dDF3KPotTo6lVBuN7uQHsimZgJHIj3Zl L7+Q== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-1005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1005-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id g29-20020a056402321d00b0055ed343be5asi2295169eda.52.2024.01.29.12.44.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 12:44:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-1005-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1005-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CDA4F1F22031 for ; Mon, 29 Jan 2024 20:44:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD473157E6B; Mon, 29 Jan 2024 20:44:01 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 030D622F0F; Mon, 29 Jan 2024 20:43:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706561041; cv=none; b=omK/JahonOFAByEbI/lhNbvmxFdzU3PQaU8qs68aWtSiheUWK4SqF6OulRzfWY3kcdEfq7yXG4OxcF//C7r2/JXat6wQ8K38YZEDIqQxbGe7iD6GHb5CyvJVw2jrPeHtgwlqc54gLG7GZsfjAFjonlQszEE59kI7ccMJupuRor4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706561041; c=relaxed/simple; bh=un4kre/ILHhmcznFdTkp80BZ85ebFf2UMSFeuyh9x9s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CNQQw3ECnSWUVrzteSPC+2tWs5kFV7b0QdJFV7cTOx8+xPdW8HKTqSbIB+QKubkgNxm4DXXnSXCAeXvoQ5bxT0jtD4p6KmynOQGlmtbxjPY2kexotJylMUMY3CJkOpnEN4VODbu6rDjrRaXhYNTcVJcBAATHcZ81iQTFPmQMTBs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de 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-out2.suse.de (Postfix) with ESMTPS id 5961B1FCFD; Mon, 29 Jan 2024 20:43:58 +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 B20A212FF7; Mon, 29 Jan 2024 20:43:57 +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 cq+xGA0OuGXiDAAAD6G6ig (envelope-from ); Mon, 29 Jan 2024 20:43:57 +0000 From: Gabriel Krisman Bertazi To: ebiggers@kernel.org, viro@zeniv.linux.org.uk, jaegeuk@kernel.org, tytso@mit.edu Cc: amir73il@gmail.com, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v5 06/12] fscrypt: Ignore plaintext dentries during d_move Date: Mon, 29 Jan 2024 17:43:24 -0300 Message-ID: <20240129204330.32346-7-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240129204330.32346-1-krisman@suse.de> References: <20240129204330.32346-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 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 5961B1FCFD X-Spam-Level: X-Spam-Score: -4.00 X-Spam-Flag: NO 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. Note that VFS will call this function for any dentry, whether the volume has fscrypt on not. But, since we only care about DCACHE_NOKEY_NAME, we can check for that, to avoid touching the superblock for other fields that identify a fscrypt volume. Note also that fscrypt_handle_d_move is hopefully inlined back into __d_move, so the call cost is not significant. Considering that DCACHE_NOKEY_NAME is a fscrypt-specific flag, we do the check in fscrypt code instead of the caller. Signed-off-by: Gabriel Krisman Bertazi --- Changes since v4: - Check based on the dentry itself (eric) --- include/linux/fscrypt.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index c1e285053b3e..ab668760d63e 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -232,6 +232,15 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode) */ static inline void fscrypt_handle_d_move(struct dentry *dentry) { + /* + * VFS calls fscrypt_handle_d_move even for non-fscrypt + * filesystems. Since we only care about DCACHE_NOKEY_NAME + * dentries here, check that to bail out quickly, if possible. + */ + if (!(dentry->d_flags & DCACHE_NOKEY_NAME)) + return; + + /* Mark the dentry as a plaintext dentry. */ dentry->d_flags &= ~DCACHE_NOKEY_NAME; /* -- 2.43.0