From patchwork Thu Jan 11 22:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517832 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2285FC47077 for ; Thu, 11 Jan 2024 22:59:13 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO412-0001ET-OP; Thu, 11 Jan 2024 22:59:12 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO40t-0001EL-6X for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=noWIkV7tDOxT+ahoicDZr82jxDDniPzXUm/ClBuwL34=; b=VR6pKcfQGOGUtC59ThCQV/2JsC 0FOpgwYUzTaIiiufqdFG+pQpkmi32TdFfJn4LPcpmY84xGl8BmgN2ilw5SUZ/Z5Vu25QtSCTPXKg7 qUQFvAbJHP3cV/9Bm9EREcH4c0H5oi+EXk1by6Sr1b1i1VDYK1QZrZqqHio/fwR3qi+U=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=noWIkV7tDOxT+ahoicDZr82jxDDniPzXUm/ClBuwL34=; b=S+bfyaeXx1n3OxmgtHQx7NajE0 xQo2RXgjbuUMbxtMmVqEjQiWLIcz8pJPWaQlHSa1lckKUSlheB1ibyGxsozeeQE405cdaAuzBCbl7 8TvnjtRliFcJQLFy3rneQd3MWvFkoVObdBAX6WSlCLBPKsiyDsTJGlXQ/tX8cGdMvQRs=; Received: from smtp-out2.suse.de ([195.135.223.131]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO40o-0005x7-5H for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:03 +0000 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 314091FB68; Thu, 11 Jan 2024 22:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013927; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=noWIkV7tDOxT+ahoicDZr82jxDDniPzXUm/ClBuwL34=; b=S3XnhC0lgOqI7rcukcYudVe474umKuuxpPX4Id3vSQIqrCziYuk077ZA3fg1R4DkZzify3 atgep2fEUOnnxH3vu55qEprRccv+EjhH3+JxFh2M/3cFbLZyybZ75JJBoE+2Nq0HnnlzGV 2AR/NrGuK9d88YM01F5K8gBwV09vLgQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013927; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=noWIkV7tDOxT+ahoicDZr82jxDDniPzXUm/ClBuwL34=; b=bVQRWEPDG90yqs5k4WKu5SEqbELGEH8fq2Y74jdfCDPbXTTqwSfGlFSAdcLSbyi0Vl13t1 mTgC8mCM9HnvsWAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013927; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=noWIkV7tDOxT+ahoicDZr82jxDDniPzXUm/ClBuwL34=; b=S3XnhC0lgOqI7rcukcYudVe474umKuuxpPX4Id3vSQIqrCziYuk077ZA3fg1R4DkZzify3 atgep2fEUOnnxH3vu55qEprRccv+EjhH3+JxFh2M/3cFbLZyybZ75JJBoE+2Nq0HnnlzGV 2AR/NrGuK9d88YM01F5K8gBwV09vLgQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013927; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=noWIkV7tDOxT+ahoicDZr82jxDDniPzXUm/ClBuwL34=; b=bVQRWEPDG90yqs5k4WKu5SEqbELGEH8fq2Y74jdfCDPbXTTqwSfGlFSAdcLSbyi0Vl13t1 mTgC8mCM9HnvsWAg== 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 B0E0913946; Thu, 11 Jan 2024 22:58:46 +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 FYfcHaZyoGVVLwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:58:46 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:07 -0300 Message-ID: <20240111225816.18117-2-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [0.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Headers-End: 1rO40o-0005x7-5H Subject: [f2fs-dev] [PATCH v3 01/10] ovl: Reject mounting case-insensitive filesystems X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net overlayfs relies on the filesystem setting DCACHE_OP_HASH or DCACHE_OP_COMPARE to reject mounting over case-insensitive directories. Since commit bb9cd9106b22 ("fscrypt: Have filesystems handle their d_ops"), we set ->d_op through a hook in ->d_lookup, which means the root dentry won't have them, causing the mount to accidentally succeed. In v6.7-rc7, the following sequence will succeed to mount, but any dentry other than the root dentry will be a "weird" dentry to ovl and fail with EREMOTE. mkfs.ext4 -O casefold lower.img mount -O loop lower.img lower mount -t overlay -o lowerdir=lower,upperdir=upper,workdir=work ovl /mnt Mounting on a subdirectory fails, as expected, because DCACHE_OP_HASH and DCACHE_OP_COMPARE are properly set by ->lookup. Fix by explicitly rejecting superblocks that allow case-insensitive dentries. While there, re-sort the entries to have more descriptive error messages first. Fixes: bb9cd9106b22 ("fscrypt: Have filesystems handle their d_ops") Signed-off-by: Gabriel Krisman Bertazi Acked-by: Amir Goldstein --- changes since v2: - Re-sort checks to trigger more descriptive error messages first (Amir) - Add code comment (Amir) --- fs/overlayfs/params.c | 13 ++++++++++--- include/linux/fs.h | 9 +++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c index 3fe2dde1598f..09a4973f26f9 100644 --- a/fs/overlayfs/params.c +++ b/fs/overlayfs/params.c @@ -280,12 +280,19 @@ static int ovl_mount_dir_check(struct fs_context *fc, const struct path *path, { struct ovl_fs_context *ctx = fc->fs_private; - if (ovl_dentry_weird(path->dentry)) - return invalfc(fc, "filesystem on %s not supported", name); - if (!d_is_dir(path->dentry)) return invalfc(fc, "%s is not a directory", name); + /* + * Root dentries of case-insensitive filesystems might not have + * the dentry operations set, but still be incompatible with + * overlayfs. Check explicitly to prevent post-mount failures. + */ + if (sb_has_encoding(path->mnt->mnt_sb)) + return invalfc(fc, "case-insensitive filesystem on %s not supported", name); + + if (ovl_dentry_weird(path->dentry)) + return invalfc(fc, "filesystem on %s not supported", name); /* * Check whether upper path is read-only here to report failures diff --git a/include/linux/fs.h b/include/linux/fs.h index 98b7a7a8c42e..e6667ece5e64 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3203,6 +3203,15 @@ extern int generic_check_addressable(unsigned, u64); extern void generic_set_encrypted_ci_d_ops(struct dentry *dentry); +static inline bool sb_has_encoding(const struct super_block *sb) +{ +#if IS_ENABLED(CONFIG_UNICODE) + return !!sb->s_encoding; +#else + return false; +#endif +} + int may_setattr(struct mnt_idmap *idmap, struct inode *inode, unsigned int ia_valid); int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *); From patchwork Thu Jan 11 22:58:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 891BBC4707B for ; Thu, 11 Jan 2024 22:59:06 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO40u-0001qo-62; Thu, 11 Jan 2024 22:59:04 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO40r-0001qi-ET for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=I2QPSkguP3TJ/9OXXk7UjvrT0AFnjUupiXPinkoZssY=; b=QCn7Rt+EYX167mqMFk3ZvL62lS U37lJNevrSmnD7I7QCUGoak/9ELi+RXtpYzHCS9X3pRoKLiMsfz/IwnueeB3GoIv8+DinAILvsPgO l43yksjrTZwXdFAauMN7Eus+HDqH6IjR9oyDXJlOibGbecHUPkDh1cu+QuUJHbhcYXFo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=I2QPSkguP3TJ/9OXXk7UjvrT0AFnjUupiXPinkoZssY=; b=LMwIj/QoTzm1cdmiqlolTqwOew 9ZAyen9IJegLzd0g8RA4Gf2ufH1pFU0BpcEupu1+GoP0cJbAbpe6/B1WTd8/yFJ9QY7hB8uHlIkat gwjgsGCI+PnlZ2KZWmOq/8H14DChXl4HcmVZS7xsO8wHoqwU6Rm8KUMipCFVuVp9iU3c=; Received: from smtp-out2.suse.de ([195.135.223.131]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO40m-0005wz-9g for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:01 +0000 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 574BC1FB69; Thu, 11 Jan 2024 22:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013930; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I2QPSkguP3TJ/9OXXk7UjvrT0AFnjUupiXPinkoZssY=; b=prJXXoapVansQQZSZbvjqyRzFzrwc+KDOrOKUgP9OwnHEFSsCEzhy8x6n+XY0JmKgOl22i h0+ETA78g6SqESx/0Wz3eJ9Xr+sou+iaoFCv8Pw/2lAqexJ9XEPx1fz2Hzn4TZeJa4MNfJ 3BrvsMcuPIQA+xa/v7xHjbLq6Gi8cns= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013930; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I2QPSkguP3TJ/9OXXk7UjvrT0AFnjUupiXPinkoZssY=; b=PJkK3BuVUTJnJxcSx+wCa3IUrIrFMj5fkHp1TOsNUQUtY2S0OEjgPeL3UWygGVBX6XEGbO hIUZZpZE77ioP3Bw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013930; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I2QPSkguP3TJ/9OXXk7UjvrT0AFnjUupiXPinkoZssY=; b=prJXXoapVansQQZSZbvjqyRzFzrwc+KDOrOKUgP9OwnHEFSsCEzhy8x6n+XY0JmKgOl22i h0+ETA78g6SqESx/0Wz3eJ9Xr+sou+iaoFCv8Pw/2lAqexJ9XEPx1fz2Hzn4TZeJa4MNfJ 3BrvsMcuPIQA+xa/v7xHjbLq6Gi8cns= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013930; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I2QPSkguP3TJ/9OXXk7UjvrT0AFnjUupiXPinkoZssY=; b=PJkK3BuVUTJnJxcSx+wCa3IUrIrFMj5fkHp1TOsNUQUtY2S0OEjgPeL3UWygGVBX6XEGbO hIUZZpZE77ioP3Bw== 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 D75E413946; Thu, 11 Jan 2024 22:58:49 +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 469cJ6lyoGVaLwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:58:49 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:08 -0300 Message-ID: <20240111225816.18117-3-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [0.70 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[9]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[] X-Headers-End: 1rO40m-0005wz-9g Subject: [f2fs-dev] [PATCH v3 02/10] fscrypt: Share code between functions that prepare lookup X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Right now, we have two functions that can be called by the filesystem during lookup to set up fscrypt internal state for the dentry and inode under lookup: 1) fscrypt_prepare_lookup_dentry_partial: used only by ceph. It sets encryption information in the inode and sets the dentry flag if the key is not available. 2) fscrypt_prepare_lookup: used by everything else. Does all the above, plus also sets struct fname. This patch refactors the code to implement the later using the former. This way, we'll have a single place where we set DCACHE_NOKEY_NAME, in preparation to add more churn to that condition in the following patch. To make the patch simpler, we now call fscrypt_get_encryption_info twice for fscrypt_prepare_lookup, once inside fscrypt_setup_filename and once inside fscrypt_prepare_lookup_dentry. It seems safe to do, and considering it will bail early in the second lookup and most lookups should go to the dcache anyway, it doesn't seem problematic for performance. In addition, we add a function call for the unencrypted case, also during lookup. Apart from the above, it should have no behavior change. I tested ext4/f2fs manually and with fstests, which yielded no regressions. Signed-off-by: Gabriel Krisman Bertazi --- fs/ceph/dir.c | 2 +- fs/ceph/file.c | 2 +- fs/crypto/hooks.c | 53 ++++++++++++++++++----------------------- include/linux/fscrypt.h | 40 +++++++++++++++++-------------- 4 files changed, 47 insertions(+), 50 deletions(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 91709934c8b1..835421e2845d 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -813,7 +813,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry, if (IS_ENCRYPTED(dir)) { bool had_key = fscrypt_has_encryption_key(dir); - err = fscrypt_prepare_lookup_partial(dir, dentry); + err = fscrypt_prepare_lookup_dentry(dir, dentry); if (err < 0) return ERR_PTR(err); diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 3b5aae29e944..5c9206670533 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -812,7 +812,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, ihold(dir); if (IS_ENCRYPTED(dir)) { set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags); - err = fscrypt_prepare_lookup_partial(dir, dentry); + err = fscrypt_prepare_lookup_dentry(dir, dentry); if (err < 0) goto out_req; } diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c index 52504dd478d3..41df986d1230 100644 --- a/fs/crypto/hooks.c +++ b/fs/crypto/hooks.c @@ -94,52 +94,45 @@ int __fscrypt_prepare_rename(struct inode *old_dir, struct dentry *old_dentry, } EXPORT_SYMBOL_GPL(__fscrypt_prepare_rename); -int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry, - struct fscrypt_name *fname) -{ - int err = fscrypt_setup_filename(dir, &dentry->d_name, 1, fname); - - if (err && err != -ENOENT) - return err; - - if (fname->is_nokey_name) { - spin_lock(&dentry->d_lock); - dentry->d_flags |= DCACHE_NOKEY_NAME; - spin_unlock(&dentry->d_lock); - } - return err; -} -EXPORT_SYMBOL_GPL(__fscrypt_prepare_lookup); - /** - * fscrypt_prepare_lookup_partial() - prepare lookup without filename setup + * fscrypt_prepare_lookup_dentry() - prepare lookup without filename setup * @dir: the encrypted directory being searched * @dentry: the dentry being looked up in @dir * - * This function should be used by the ->lookup and ->atomic_open methods of - * filesystems that handle filename encryption and no-key name encoding - * themselves and thus can't use fscrypt_prepare_lookup(). Like - * fscrypt_prepare_lookup(), this will try to set up the directory's encryption - * key and will set DCACHE_NOKEY_NAME on the dentry if the key is unavailable. - * However, this function doesn't set up a struct fscrypt_name for the filename. + * This function should be used by the ->lookup and ->atomic_open + * methods of filesystems that handle filename encryption and no-key + * name encoding themselves and thus can't use fscrypt_prepare_lookup() + * directly. This will try to set up the directory's encryption key and + * will set DCACHE_NOKEY_NAME on the dentry if the key is unavailable. + * However, this function doesn't set up a struct fscrypt_name for the + * filename. * * Return: 0 on success; -errno on error. Note that the encryption key being * unavailable is not considered an error. It is also not an error if * the encryption policy is unsupported by this kernel; that is treated * like the key being unavailable, so that files can still be deleted. */ -int fscrypt_prepare_lookup_partial(struct inode *dir, struct dentry *dentry) +int fscrypt_prepare_lookup_dentry(struct inode *dir, + struct dentry *dentry) { - int err = fscrypt_get_encryption_info(dir, true); + bool nokey_name = false; + int err = 0; - if (!err && !fscrypt_has_encryption_key(dir)) { - spin_lock(&dentry->d_lock); + if (IS_ENCRYPTED(dir)) { + err = fscrypt_get_encryption_info(dir, true); + if (!err && !fscrypt_has_encryption_key(dir)) + nokey_name = true; + } + + spin_lock(&dentry->d_lock); + if (nokey_name) { dentry->d_flags |= DCACHE_NOKEY_NAME; - spin_unlock(&dentry->d_lock); } + spin_unlock(&dentry->d_lock); + return err; } -EXPORT_SYMBOL_GPL(fscrypt_prepare_lookup_partial); +EXPORT_SYMBOL_GPL(fscrypt_prepare_lookup_dentry); int __fscrypt_prepare_readdir(struct inode *dir) { diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index 12f9e455d569..3801c5c94fb6 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -382,9 +382,7 @@ int __fscrypt_prepare_link(struct inode *inode, struct inode *dir, int __fscrypt_prepare_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags); -int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry, - struct fscrypt_name *fname); -int fscrypt_prepare_lookup_partial(struct inode *dir, struct dentry *dentry); +int fscrypt_prepare_lookup_dentry(struct inode *dir, struct dentry *dentry); int __fscrypt_prepare_readdir(struct inode *dir); int __fscrypt_prepare_setattr(struct dentry *dentry, struct iattr *attr); int fscrypt_prepare_setflags(struct inode *inode, @@ -704,14 +702,7 @@ static inline int __fscrypt_prepare_rename(struct inode *old_dir, return -EOPNOTSUPP; } -static inline int __fscrypt_prepare_lookup(struct inode *dir, - struct dentry *dentry, - struct fscrypt_name *fname) -{ - return -EOPNOTSUPP; -} - -static inline int fscrypt_prepare_lookup_partial(struct inode *dir, +static inline int fscrypt_prepare_lookup_dentry(struct inode *dir, struct dentry *dentry) { return -EOPNOTSUPP; @@ -975,14 +966,27 @@ static inline int fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry, struct fscrypt_name *fname) { - if (IS_ENCRYPTED(dir)) - return __fscrypt_prepare_lookup(dir, dentry, fname); + int ret, err = 0; + + if (IS_ENCRYPTED(dir)) { + err = fscrypt_setup_filename(dir, &dentry->d_name, 1, fname); + if (err && err != -ENOENT) + return err; + } else { + memset(fname, 0, sizeof(*fname)); + fname->usr_fname = &dentry->d_name; + fname->disk_name.name = (unsigned char *)dentry->d_name.name; + fname->disk_name.len = dentry->d_name.len; + } - memset(fname, 0, sizeof(*fname)); - fname->usr_fname = &dentry->d_name; - fname->disk_name.name = (unsigned char *)dentry->d_name.name; - fname->disk_name.len = dentry->d_name.len; - return 0; + /* + * fscrypt_prepare_lookup_dentry will succeed even if the + * directory key is unavailable but the filename isn't a valid + * no-key name (-ENOENT). Thus, propagate the previous + * error, if any. + */ + ret = fscrypt_prepare_lookup_dentry(dir, dentry); + return err ? err : ret; } /** From patchwork Thu Jan 11 22:58:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBDF8C4707B for ; Thu, 11 Jan 2024 22:59:18 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO417-0000Zh-GH; Thu, 11 Jan 2024 22:59:18 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO40x-0000ZP-VU for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=icfpDa9cQWSMCJ3qgTlqcSwaA2iZOw9bqJdb6XgXsH8=; b=AB/uetPvC8zouKyQlzVFaM+dBA A5qIA+kEJRWANpB7u4SbAzYHC5+J5cC+gf82ahbuqcsisOAIjL5XQlXEkSKXvrYAAlN1wwUAsDVuL iRQoEzaBzs/InAjPz72eyU+U3Hf3/AocVjG3B7Gy2Sc5c7Wcfd5A8te7Lc4G+SqC7ByI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=icfpDa9cQWSMCJ3qgTlqcSwaA2iZOw9bqJdb6XgXsH8=; b=ha0a15k6IDsO4M5pm0TzlFknpY dxwddm72/qoZyL6Fv4tCIaregdSCnBpnudwpiP+t2xQZTQplMlrRw70Wa8bFAbnqt7ml+9O2egYMO 0C8RiRHnAyNU3aL/9YPGSkDbH1fAqVSyLRa80ZH7Fb/3kgsttCigTPuUIclwzoFPVJXU=; Received: from smtp-out1.suse.de ([195.135.223.130]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO40u-0005xO-Jh for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:08 +0000 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 A5CC52224C; Thu, 11 Jan 2024 22:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013933; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=icfpDa9cQWSMCJ3qgTlqcSwaA2iZOw9bqJdb6XgXsH8=; b=mZDO2nNrpqHQMxg8euhKqdOuPjYCb/FFILlqbK6LTximzV6F67BWOOzkHex/xiTWBG6OJY VhwGJe74+sdDs4oijT0DIFoI/cPpXqmRL/X2k51HMo0N5CXgmUnrrj4fPskMK4Ju1Ekn2I 9Dmhh0WdRNLPFzPLIIqnC17jRY+d+wY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013933; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=icfpDa9cQWSMCJ3qgTlqcSwaA2iZOw9bqJdb6XgXsH8=; b=mBc57u00PH/hw+n8mGU5jVB7oke0VDIvO1byYPDa/eZclL4jSOHDQBD1kBOOa2QZVFUf3+ 2JN/Ek7GE5eO0dBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013933; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=icfpDa9cQWSMCJ3qgTlqcSwaA2iZOw9bqJdb6XgXsH8=; b=mZDO2nNrpqHQMxg8euhKqdOuPjYCb/FFILlqbK6LTximzV6F67BWOOzkHex/xiTWBG6OJY VhwGJe74+sdDs4oijT0DIFoI/cPpXqmRL/X2k51HMo0N5CXgmUnrrj4fPskMK4Ju1Ekn2I 9Dmhh0WdRNLPFzPLIIqnC17jRY+d+wY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013933; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=icfpDa9cQWSMCJ3qgTlqcSwaA2iZOw9bqJdb6XgXsH8=; b=mBc57u00PH/hw+n8mGU5jVB7oke0VDIvO1byYPDa/eZclL4jSOHDQBD1kBOOa2QZVFUf3+ 2JN/Ek7GE5eO0dBw== 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 0B5DB13946; Thu, 11 Jan 2024 22:58:52 +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 RHP+MKxyoGVeLwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:58:52 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:09 -0300 Message-ID: <20240111225816.18117-4-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [4.41 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.49)[79.74%] X-Headers-End: 1rO40u-0005xO-Jh Subject: [f2fs-dev] [PATCH v3 03/10] fscrypt: Drop d_revalidate for valid dentries during lookup X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Unencrypted and encrypted-dentries where the key is available don't need to be revalidated with regards to fscrypt, since they don't go stale from under VFS and the key cannot be removed for the encrypted case without evicting the dentry. Mark them with d_set_always_valid, to avoid unnecessary revalidation, in preparation to always configuring d_op through sb->s_d_op. Since the filesystem might have other features that require revalidation, only apply this optimization if the d_revalidate handler is fscrypt_d_revalidate itself. Signed-off-by: Gabriel Krisman Bertazi --- fs/crypto/hooks.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c index 41df986d1230..53381acc83e7 100644 --- a/fs/crypto/hooks.c +++ b/fs/crypto/hooks.c @@ -127,6 +127,15 @@ int fscrypt_prepare_lookup_dentry(struct inode *dir, spin_lock(&dentry->d_lock); if (nokey_name) { dentry->d_flags |= DCACHE_NOKEY_NAME; + } 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. + */ + dentry->d_flags &= ~DCACHE_OP_REVALIDATE; } spin_unlock(&dentry->d_lock); From patchwork Thu Jan 11 22:58:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517836 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68449C47258 for ; Thu, 11 Jan 2024 22:59:20 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO419-0001s0-ND; Thu, 11 Jan 2024 22:59:19 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO40x-0001r2-5y for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WvMDsNpWtpVkyHe6WBfOyf6JXsaX65CnVzqgA16TQlI=; b=JKjYz58jtxPZ3rlrUCzfC+gvlK W1uPbE0orYl+i/7y5DG11jY+Q1WZY8nA7TCcvD0x8TE7ccsdfsW7O5zaJbUgNi1DsQmWtKgk/joTu d0N0SQEJ/ZXiKi4sZ4ISCGx3aLbpw7hvQ0m0nySMkjIMoeIhGwo0kwGnKsOYmk+fc6wM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WvMDsNpWtpVkyHe6WBfOyf6JXsaX65CnVzqgA16TQlI=; b=LEfDokI9NtxQzpLXYDtwWvcrEF SiB7Clam8QBx7EcRopKzgJYfCvb1N8od6cUQBanMKu2Lb+DcSCicvpJUwZcvFR5ax4KXTKC3ffuRB mqyRC0Z4Na9kOo432gfbX34VGIMoikkhTzMfH5VxdKcIizYA9pWkAH1YF29IZES+7nL4=; Received: from smtp-out2.suse.de ([195.135.223.131]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO40s-0005xK-PH for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:07 +0000 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 D53DB1FBCD; Thu, 11 Jan 2024 22:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WvMDsNpWtpVkyHe6WBfOyf6JXsaX65CnVzqgA16TQlI=; b=PyLgoTQ8LVdvyeW6nOHm73D3okXq4TtCxccPfFNFM3QVfqQtyRNs0TBUCPWsOHw3gn68q4 zk4+9dVrLi77IZU8suhWyOdcMv9FgN6pbqJnrandXhueNlYgmdKUYgXZQxpG8MB96N8hwP cYCYUBHVWTOchirpECUW8xC1F9Zkv7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WvMDsNpWtpVkyHe6WBfOyf6JXsaX65CnVzqgA16TQlI=; b=OXpL4maA8vGfP71gFRyvdUGb5wlY/Y8FeQoB8CoEAkjqvSKU06wMvOIoo9j/SP87dJLOiU p1HZjEey5b5wvbDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WvMDsNpWtpVkyHe6WBfOyf6JXsaX65CnVzqgA16TQlI=; b=PyLgoTQ8LVdvyeW6nOHm73D3okXq4TtCxccPfFNFM3QVfqQtyRNs0TBUCPWsOHw3gn68q4 zk4+9dVrLi77IZU8suhWyOdcMv9FgN6pbqJnrandXhueNlYgmdKUYgXZQxpG8MB96N8hwP cYCYUBHVWTOchirpECUW8xC1F9Zkv7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013936; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WvMDsNpWtpVkyHe6WBfOyf6JXsaX65CnVzqgA16TQlI=; b=OXpL4maA8vGfP71gFRyvdUGb5wlY/Y8FeQoB8CoEAkjqvSKU06wMvOIoo9j/SP87dJLOiU p1HZjEey5b5wvbDg== 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 4EF4113946; Thu, 11 Jan 2024 22:58:56 +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 NeaxBbByoGVkLwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:58:56 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:10 -0300 Message-ID: <20240111225816.18117-5-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [4.89 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_RATELIMIT(0.00)[to_ip_from(RLzk7q5dcbbphp39zi8hi5jhbt)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.01)[50.21%] X-Headers-End: 1rO40s-0005xK-PH Subject: [f2fs-dev] [PATCH v3 04/10] fscrypt: Drop d_revalidate once the key is added X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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. Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - Do it when moving instead of when revalidating the dentry. (me) Changes since v1: - Improve commit message (Eric) - Drop & in function comparison (Eric) --- include/linux/fscrypt.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index 3801c5c94fb6..379b423802fa 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -192,6 +192,8 @@ struct fscrypt_operations { unsigned int *num_devs); }; +int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags); + static inline struct fscrypt_inode_info * fscrypt_get_inode_info(const struct inode *inode) { @@ -230,6 +232,14 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode) static inline void fscrypt_handle_d_move(struct dentry *dentry) { dentry->d_flags &= ~DCACHE_NOKEY_NAME; + + /* + * Save the d_revalidate call cost during VFS operations. We + * can do it because, when the key is available, the dentry + * can't go stale and the key won't go away without eviction. + */ + if (dentry->d_op->d_revalidate == fscrypt_d_revalidate) + dentry->d_flags &= ~DCACHE_OP_REVALIDATE; } /** @@ -368,7 +378,6 @@ int fscrypt_fname_disk_to_usr(const struct inode *inode, bool fscrypt_match_name(const struct fscrypt_name *fname, const u8 *de_name, u32 de_name_len); u64 fscrypt_fname_siphash(const struct inode *dir, const struct qstr *name); -int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags); /* bio.c */ bool fscrypt_decrypt_bio(struct bio *bio); From patchwork Thu Jan 11 22:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68B88C47077 for ; Thu, 11 Jan 2024 22:59:18 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO417-0001rN-Jx; Thu, 11 Jan 2024 22:59:17 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO412-0001r9-5A for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5LTCLhiM/0w+aHgqPUYmBgmxvsiEHxwft6QE+saHzb8=; b=hUaVmT4vAnHaJ0Epu/8s4jnINX qMKTkAzjETwhUAE1CvgFxlSr1q4AvECLSlOn3yUAzt0ef104T8ESehFu2lvLJTE/uD4f3CHXVzl6P xsxbad+q91qrSQFJfa6bQVKgIujPNlGGdIkyiMzSGDPly2HqVvyDZCvQvhibbmadn6VM=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5LTCLhiM/0w+aHgqPUYmBgmxvsiEHxwft6QE+saHzb8=; b=DE2Sw8YtH7LWbw5ylZ/1NyjHop 1NO1Npa8lqDOmX3ybe+I1Y5jXmVyjGoz+w1Tnc8CEux5ZCIna0rp0O9MiAJTMe2H2m6cjQofk8Tr8 iFwF1agtdBG9BXooud/HUGTfcxVOg+yVIIk9rBwRYinVTLU75q0mDCZhoNlrmyhloVJs=; Received: from smtp-out1.suse.de ([195.135.223.130]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO40v-0005xX-TQ for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:10 +0000 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 EC0E02224D; Thu, 11 Jan 2024 22:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013940; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5LTCLhiM/0w+aHgqPUYmBgmxvsiEHxwft6QE+saHzb8=; b=0cDcmnQ/1cRD2JQFnMbkzufdDM9JkIE1sPO1go4UNeBVWlCsBQPIIHuuKg2zsGpJQ4Gh+o TTeV01TbZFxCXpgHziIew6O+iYkoPz4fzKklDkOguo3ZJC8nr/x1EN5WHGgjm5suieW78p BWxUWi5SWOixOOXzAeFHMXYHNu5C1K8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013940; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5LTCLhiM/0w+aHgqPUYmBgmxvsiEHxwft6QE+saHzb8=; b=msCxUqTg3P7uAk9FvlOEDKGMOqc5ciHUu2oc2jrRR7xbUynqjWGNFgWxaMhIqUdMjjDe1X 2UKzXpWzj7w57CAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013939; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5LTCLhiM/0w+aHgqPUYmBgmxvsiEHxwft6QE+saHzb8=; b=ZD0cI3CVEMcj++DkA+cHW3zR1fpO1yFGk3zFGec1l6VGi1f0UviFChsMcG0DBfXs0qjin1 /N+AwODwdb3PGo5KvQkznoZlAKZf+BBWI3ujwWwPxD5TFw3sqFARQqkFUunGNewNXx8pBk zGvvRgLYXmhbCOs/70eWAp0fQaLDX+U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013939; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5LTCLhiM/0w+aHgqPUYmBgmxvsiEHxwft6QE+saHzb8=; b=vWP4odJ89rom9EWohNNZ+OLSuZ343ZotROYc/ycHg+vHl6ihTxHSVjXEbaSOmJemsHhcaV quq+tcxCpWNLpYBA== 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 7716F13946; Thu, 11 Jan 2024 22:58:59 +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 p5ILD7NyoGVnLwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:58:59 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:11 -0300 Message-ID: <20240111225816.18117-6-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ZD0cI3CV; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=vWP4odJ8 X-Spamd-Result: default: False [4.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: EC0E02224D X-Spamd-Bar: ++++ X-Headers-End: 1rO40v-0005xX-TQ Subject: [f2fs-dev] [PATCH v3 05/10] libfs: Merge encrypted_ci_dentry_ops and ci_dentry_ops X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net In preparation to get case-insensitive dentry operations from sb->s_d_op again, use the same structure for case-insensitive filesystems with and without fscrypt. This means that on a casefolded filesystem without fscrypt, we end up having to call fscrypt_d_revalidate once per dentry, which does the function call extra cost. We could avoid it by calling d_set_always_valid in generic_set_encrypted_ci_d_ops, but this entire function will go away in the following patches, and it is not worth the extra complexity. Also, since the first fscrypt_d_revalidate will call d_set_always_valid for us, we'll only have only pay the cost once, and not per-lookup. Signed-off-by: Gabriel Krisman Bertazi --- Changes since v1: - fix header guard (eric) --- fs/libfs.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index c2aa6fd4795c..c4be0961faf0 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1776,19 +1776,14 @@ static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) static const struct dentry_operations generic_ci_dentry_ops = { .d_hash = generic_ci_d_hash, .d_compare = generic_ci_d_compare, -}; -#endif - #ifdef CONFIG_FS_ENCRYPTION -static const struct dentry_operations generic_encrypted_dentry_ops = { .d_revalidate = fscrypt_d_revalidate, +#endif }; #endif -#if defined(CONFIG_FS_ENCRYPTION) && IS_ENABLED(CONFIG_UNICODE) -static const struct dentry_operations generic_encrypted_ci_dentry_ops = { - .d_hash = generic_ci_d_hash, - .d_compare = generic_ci_d_compare, +#ifdef CONFIG_FS_ENCRYPTION +static const struct dentry_operations generic_encrypted_dentry_ops = { .d_revalidate = fscrypt_d_revalidate, }; #endif @@ -1809,38 +1804,21 @@ static const struct dentry_operations generic_encrypted_ci_dentry_ops = { * Encryption works differently in that the only dentry operation it needs is * d_revalidate, which it only needs on dentries that have the no-key name flag. * The no-key flag can't be set "later", so we don't have to worry about that. - * - * Finally, to maximize compatibility with overlayfs (which isn't compatible - * with certain dentry operations) and to avoid taking an unnecessary - * performance hit, we use custom dentry_operations for each possible - * combination rather than always installing all operations. */ void generic_set_encrypted_ci_d_ops(struct dentry *dentry) { -#ifdef CONFIG_FS_ENCRYPTION - bool needs_encrypt_ops = dentry->d_flags & DCACHE_NOKEY_NAME; -#endif #if IS_ENABLED(CONFIG_UNICODE) - bool needs_ci_ops = dentry->d_sb->s_encoding; -#endif -#if defined(CONFIG_FS_ENCRYPTION) && IS_ENABLED(CONFIG_UNICODE) - if (needs_encrypt_ops && needs_ci_ops) { - d_set_d_op(dentry, &generic_encrypted_ci_dentry_ops); + if (dentry->d_sb->s_encoding) { + d_set_d_op(dentry, &generic_ci_dentry_ops); return; } #endif #ifdef CONFIG_FS_ENCRYPTION - if (needs_encrypt_ops) { + if (dentry->d_flags & DCACHE_NOKEY_NAME) { d_set_d_op(dentry, &generic_encrypted_dentry_ops); return; } #endif -#if IS_ENABLED(CONFIG_UNICODE) - if (needs_ci_ops) { - d_set_d_op(dentry, &generic_ci_dentry_ops); - return; - } -#endif } EXPORT_SYMBOL(generic_set_encrypted_ci_d_ops); From patchwork Thu Jan 11 22:58:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3E452C47DA2 for ; Thu, 11 Jan 2024 22:59:21 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO41A-0001sB-IV; Thu, 11 Jan 2024 22:59:20 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO415-0001ra-EV for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7n1vpYH9zMkx8GCAKMQ38/U0hkGRlRzMkf9u51OH3zI=; b=hykg0WC1BEemD34gv2TK/04uqy EPpb8UUuBjLAHGkEJxTpZyLwDFe+MitaQNhTMdGjKkc4MIpDDpJPYiyEUjvZEmEb9Mqc2O/LCGwAM K3JC2VuoyHl621jVPnFlHlzD9trElGSeiDflUxEdem0lgLpKCQbk0+UmV2EI02QZYfuI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7n1vpYH9zMkx8GCAKMQ38/U0hkGRlRzMkf9u51OH3zI=; b=myU9U0SQbFEHpnJGYiFomGOubW omY8I8UifP0Me+e0YqUmSoruscZFsJHSQjMj877qI5EqjNtZ3Z5cRihZ4xH/+Z5tamwIsaA0Imheg bTvmVWgFsCvz2YMK2WmHO+AZgu9xG7J6qF/vqO3XeHfsYEKp7TtBG/8BFO5kg5jqf+lI=; Received: from smtp-out2.suse.de ([195.135.223.131]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO414-0005y2-1b for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:15 +0000 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 1862E1F74A; Thu, 11 Jan 2024 22:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7n1vpYH9zMkx8GCAKMQ38/U0hkGRlRzMkf9u51OH3zI=; b=mcr8BVPOMlyrW/y5uRS8W69VXKxrgDfSTctCVzgMqTiGQZWPL6MVtkK42B66vrpTQelPWe Avf4Xw9LFdwUq+wmTTJ2gaZsqmai/jTwRapdAfZte3xL3IFEZ4VJGAoeML4pC8xGfzx50m MVyewx5+cG1rCHAz4Mgj6jSfVj8TRbE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7n1vpYH9zMkx8GCAKMQ38/U0hkGRlRzMkf9u51OH3zI=; b=+kBhDoA/qsv7C5UHR35MEVsWGWyPLCJ7IMDNoaTVKJjJOdcG4d787zOzTbyqDfm++m6eLO GPIbicf92vAPVxBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7n1vpYH9zMkx8GCAKMQ38/U0hkGRlRzMkf9u51OH3zI=; b=mcr8BVPOMlyrW/y5uRS8W69VXKxrgDfSTctCVzgMqTiGQZWPL6MVtkK42B66vrpTQelPWe Avf4Xw9LFdwUq+wmTTJ2gaZsqmai/jTwRapdAfZte3xL3IFEZ4VJGAoeML4pC8xGfzx50m MVyewx5+cG1rCHAz4Mgj6jSfVj8TRbE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013943; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7n1vpYH9zMkx8GCAKMQ38/U0hkGRlRzMkf9u51OH3zI=; b=+kBhDoA/qsv7C5UHR35MEVsWGWyPLCJ7IMDNoaTVKJjJOdcG4d787zOzTbyqDfm++m6eLO GPIbicf92vAPVxBg== 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 9609013946; Thu, 11 Jan 2024 22:59:02 +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 p+JmF7ZyoGVuLwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:59:02 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:12 -0300 Message-ID: <20240111225816.18117-7-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 X-Spamd-Bar: +++ Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=mcr8BVPO; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="+kBhDoA/" X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [3.49 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[9]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[10.57%]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Queue-Id: 1862E1F74A X-Headers-End: 1rO414-0005y2-1b Subject: [f2fs-dev] [PATCH v3 06/10] libfs: Add helper to choose dentry operations at mount X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net In preparation to drop the similar helper that sets d_op at lookup time, add a version to set the right d_op filesystem-wide, through sb->s_d_op. The operations structures are shared across filesystems supporting fscrypt and/or casefolding, therefore we can keep it in common libfs code. Signed-off-by: Gabriel Krisman Bertazi --- fs/libfs.c | 29 +++++++++++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 30 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index c4be0961faf0..9cd4df6969d2 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1822,6 +1822,35 @@ void generic_set_encrypted_ci_d_ops(struct dentry *dentry) } EXPORT_SYMBOL(generic_set_encrypted_ci_d_ops); +/** + * generic_set_sb_d_ops - helper for choosing the set of + * filesystem-wide dentry operations for the enabled features + * @sb: superblock to be configured + * + * Filesystems supporting casefolding and/or fscrypt can call this + * helper at mount-time to configure sb->s_d_root to best set of dentry + * operations required for the enabled features. The helper must be + * called after these have been configured, but before the root + * dentry is created. + * + */ +void generic_set_sb_d_ops(struct super_block *sb) +{ +#if IS_ENABLED(CONFIG_UNICODE) + if (sb->s_encoding) { + sb->s_d_op = &generic_ci_dentry_ops; + return; + } +#endif +#ifdef CONFIG_FS_ENCRYPTION + if (sb->s_cop) { + sb->s_d_op = &generic_encrypted_dentry_ops; + return; + } +#endif +} +EXPORT_SYMBOL(generic_set_sb_d_ops); + /** * inode_maybe_inc_iversion - increments i_version * @inode: inode with the i_version that should be updated diff --git a/include/linux/fs.h b/include/linux/fs.h index e6667ece5e64..c985d9392b61 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3202,6 +3202,7 @@ extern int generic_file_fsync(struct file *, loff_t, loff_t, int); extern int generic_check_addressable(unsigned, u64); extern void generic_set_encrypted_ci_d_ops(struct dentry *dentry); +extern void generic_set_sb_d_ops(struct super_block *sb); static inline bool sb_has_encoding(const struct super_block *sb) { From patchwork Thu Jan 11 22:58:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C41BCC47DA7 for ; Thu, 11 Jan 2024 22:59:21 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO41A-0000aE-R8; Thu, 11 Jan 2024 22:59:21 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO418-0000Zx-88 for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=dAXxsZUzQs43nPmCR7QF70NpWme+IPIt3kqL7m9PrBY=; b=AOqRZwd6lRjMDA1RI/zrPRibP7 2qkRdZKMxAJi8SExrKXeLRbRkvGrz1q1tU+d2p6NhFEaS6ViSJYUkFLgQSkdpF7r+2PKGx+UbeGkq ZwZf/gWGb8TIN7XFWsTKhigMb6V/B0QvoH2JWOXu7bqgi0i+4JqhrAqw0aZp4Tg4CxTw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=dAXxsZUzQs43nPmCR7QF70NpWme+IPIt3kqL7m9PrBY=; b=ircck7k9Aq+mKW9LYUWSZJkzE4 AWpPY32xmteRYbL0hBNnA1FEfZrPp3VU1wc/mqPRULukr1alb3ituBhuWdcSkXY3Pb9PaJzIjqnJu R2aTFr++1e+0SziZFjHmW9xDAKduvNmVqqGJOC7qHEq43p9GPA33haTl+xahAWTgcf5I=; Received: from smtp-out2.suse.de ([195.135.223.131]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO417-0005yH-7q for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:18 +0000 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 4A5351FB68; Thu, 11 Jan 2024 22:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dAXxsZUzQs43nPmCR7QF70NpWme+IPIt3kqL7m9PrBY=; b=Hcv3sAvJanQ5xXf7bw8gx3y4fXqEl9KU5qM9Jcw4THf6nQN9VbxAIdF04o9F9yeLqcxT+r qFX7tRjGwhrvf3smZJObaVz/hfIDhclWomgIpTGi+RKZ5CmtDCx12Cnh1whBX3PM2QkBkG e6z7FC/hxREjoBkA7ENM0UbuRuROEJw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dAXxsZUzQs43nPmCR7QF70NpWme+IPIt3kqL7m9PrBY=; b=DTV75UqvgZrSpNXvlOnwY8E9Gy2XkZlOg1lg58HbtWdFZrduwba3gf4CtYEAZCCI8C0NQz 6imqBQA5axfEJ7Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dAXxsZUzQs43nPmCR7QF70NpWme+IPIt3kqL7m9PrBY=; b=Hcv3sAvJanQ5xXf7bw8gx3y4fXqEl9KU5qM9Jcw4THf6nQN9VbxAIdF04o9F9yeLqcxT+r qFX7tRjGwhrvf3smZJObaVz/hfIDhclWomgIpTGi+RKZ5CmtDCx12Cnh1whBX3PM2QkBkG e6z7FC/hxREjoBkA7ENM0UbuRuROEJw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013946; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dAXxsZUzQs43nPmCR7QF70NpWme+IPIt3kqL7m9PrBY=; b=DTV75UqvgZrSpNXvlOnwY8E9Gy2XkZlOg1lg58HbtWdFZrduwba3gf4CtYEAZCCI8C0NQz 6imqBQA5axfEJ7Dg== 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 CA3D313946; Thu, 11 Jan 2024 22:59:05 +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 H+rXI7lyoGVwLwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:59:05 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:13 -0300 Message-ID: <20240111225816.18117-8-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Hcv3sAvJ; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=DTV75Uqv X-Spamd-Result: default: False [4.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 4A5351FB68 X-Spamd-Bar: ++++ X-Headers-End: 1rO417-0005yH-7q Subject: [f2fs-dev] [PATCH v3 07/10] ext4: Configure dentry operations at dentry-creation time X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This was already the case for case-insensitive before commit bb9cd9106b22 ("fscrypt: Have filesystems handle their d_ops"), but it was changed to set at lookup-time to facilitate the integration with fscrypt. But it's a problem because dentries that don't get created through ->lookup() won't have any visibility of the operations. Since fscrypt now also supports configuring dentry operations at creation-time, do it for any encrypted and/or casefold volume, simplifying the implementation across these features. Signed-off-by: Gabriel Krisman Bertazi --- fs/ext4/namei.c | 1 - fs/ext4/super.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index d252935f9c8a..3f0b853a371e 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1762,7 +1762,6 @@ static struct buffer_head *ext4_lookup_entry(struct inode *dir, struct buffer_head *bh; err = ext4_fname_prepare_lookup(dir, dentry, &fname); - generic_set_encrypted_ci_d_ops(dentry); if (err == -ENOENT) return NULL; if (err) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index c5fcf377ab1f..de80a9cc699a 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5493,6 +5493,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) goto failed_mount4; } + generic_set_sb_d_ops(sb); sb->s_root = d_make_root(root); if (!sb->s_root) { ext4_msg(sb, KERN_ERR, "get root dentry failed"); From patchwork Thu Jan 11 22:58:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517838 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5D30C47077 for ; Thu, 11 Jan 2024 22:59:23 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO41D-0001s3-0s; Thu, 11 Jan 2024 22:59:23 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO41B-0001rs-LS for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tlx4z3N508ykO+IPN4KGQgLY91vQLkOc0l8vpLCa86g=; b=WKnOqF+7z0bUXdl1RB7R89LLy7 Z+Ynzpwt5dTKum9/70A1CaK8u2tF0ud7ZjT+9vPFg9Tj8IiSd8fH66ZMfFFzqkV+67rBIrkHCZ+nS 3Vxdm/TlSRKzCVzTtDE8/XlL5zS+4DXambN/E+fOBYmIKe9VOhYO7+iUnhXRBfl2vEQE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tlx4z3N508ykO+IPN4KGQgLY91vQLkOc0l8vpLCa86g=; b=N71TQomDKaw9SAyt/TgSJCbYJd f/QwP47AoNbwW/C1VykXjvvlCTvwygn7CcTNT0L1H4u44A7yHizGQAVvQWCN1TTLGNQun/P/nOcV+ OzSGeRXf+PnXo+IsrxKzaDhHa8gnMOl3qGQsFcpVfnd5mzy25Pf0onbX1D3vsOULnfKc=; Received: from smtp-out1.suse.de ([195.135.223.130]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO41A-0005yP-Aq for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:21 +0000 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 602D22224C; Thu, 11 Jan 2024 22:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tlx4z3N508ykO+IPN4KGQgLY91vQLkOc0l8vpLCa86g=; b=02OQgoJrXLKm5+07YhJYO53sXqPek+weDy9gE/fRyuJXQXVD2kP0iZgG70HoTkc/06SUV6 BhMNQgaf7Z05s1uEYrANcw+WOwM/wa9sDL++7AAJ27iyuMEqIjNehAXF8S+siAoyWlS+uX ekGrHSJ7QGkJBXq1tY7+59DAJlj2BgM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tlx4z3N508ykO+IPN4KGQgLY91vQLkOc0l8vpLCa86g=; b=wSmelV1r+X2TE+YWfqG9wLU8EiAmC0UA4wNIe6WRUYDAoULpMAmV7c2WRjRavpqRrpRaAw WPEqteaw1uCcBACQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tlx4z3N508ykO+IPN4KGQgLY91vQLkOc0l8vpLCa86g=; b=02OQgoJrXLKm5+07YhJYO53sXqPek+weDy9gE/fRyuJXQXVD2kP0iZgG70HoTkc/06SUV6 BhMNQgaf7Z05s1uEYrANcw+WOwM/wa9sDL++7AAJ27iyuMEqIjNehAXF8S+siAoyWlS+uX ekGrHSJ7QGkJBXq1tY7+59DAJlj2BgM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tlx4z3N508ykO+IPN4KGQgLY91vQLkOc0l8vpLCa86g=; b=wSmelV1r+X2TE+YWfqG9wLU8EiAmC0UA4wNIe6WRUYDAoULpMAmV7c2WRjRavpqRrpRaAw WPEqteaw1uCcBACQ== 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 E165413946; Thu, 11 Jan 2024 22:59:08 +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 seL3KbxyoGV2LwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:59:08 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:14 -0300 Message-ID: <20240111225816.18117-9-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [4.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_RATELIMIT(0.00)[to_ip_from(RLzk7q5dcbbphp39zi8hi5jhbt)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[] X-Headers-End: 1rO41A-0005yP-Aq Subject: [f2fs-dev] [PATCH v3 08/10] f2fs: Configure dentry operations at dentry-creation time X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This was already the case for case-insensitive before commit bb9cd9106b22 ("fscrypt: Have filesystems handle their d_ops"), but it was changed to set at lookup-time to facilitate the integration with fscrypt. But it's a problem because dentries that don't get created through ->lookup() won't have any visibility of the operations. Since fscrypt now also supports configuring dentry operations at creation-time, do it for any encrypted and/or casefold volume, simplifying the implementation across these features. Signed-off-by: Gabriel Krisman Bertazi --- fs/f2fs/namei.c | 1 - fs/f2fs/super.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index d0053b0284d8..b40c6c393bd6 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -532,7 +532,6 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry, } err = f2fs_prepare_lookup(dir, dentry, &fname); - generic_set_encrypted_ci_d_ops(dentry); if (err == -ENOENT) goto out_splice; if (err) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 033af907c3b1..abfdb6e25b1c 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4663,6 +4663,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) goto free_node_inode; } + generic_set_sb_d_ops(sb); sb->s_root = d_make_root(root); /* allocate root dentry */ if (!sb->s_root) { err = -ENOMEM; From patchwork Thu Jan 11 22:58:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC51AC47077 for ; Thu, 11 Jan 2024 22:59:27 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO41H-0001FS-Eu; Thu, 11 Jan 2024 22:59:27 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO41F-0001FJ-PV for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=RVHkl1+gHuQ53whsCv6aHWAEO4kmheKoUmT6NcMFQk8=; b=SYcLYCT0Gjzk0dcOktt6InZxeY tiCAm7aXAAe8gh0hqDKdMwdf2kxJYZLt/+U1hCHBb6ko/slQC1XgKMXi+1GADfdI6roLFRQ6OQzCv VCMQVsLytX43OTXrkuLwbCDK7QqCx14Bg33yXB4qLbnL15IC+O/J15Q9ETW/wQuhWm2o=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=RVHkl1+gHuQ53whsCv6aHWAEO4kmheKoUmT6NcMFQk8=; b=WLo9AVOvPgfTreJD0vSIM+UCk7 KDkSRFonkUpQfwvH+waMfoD9/vXV9zzd9Ju/6B6CqAHzc2OY0r8b0t3BQm2RmcJFMKG3LXqsFpMiv l4hv49eUcccpYjxH3LIUPzSSHRxXBq9tZYQxD1yPOWZhf9tyLDB8+tVESW9lb2iVgK7c=; Received: from smtp-out2.suse.de ([195.135.223.131]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO41E-0005yq-GY for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:25 +0000 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 8CA181FB69; Thu, 11 Jan 2024 22:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013953; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RVHkl1+gHuQ53whsCv6aHWAEO4kmheKoUmT6NcMFQk8=; b=aJUVyOBomKHVmlh2R/j1Y/zmI8V7AkqcHHmi+2dEq1rnjy3t9PAaOPKEANz9A/53CxUFRT MY+Oh1y/moYt3LlHnhXPiylpFOAMWBoE5ohTfqyOqV3xsstjSa0cTADLiIUBTZyW/aBJqg JeSFhANhTR2O7BZSJf7eFUW2iFoa4dU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013953; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RVHkl1+gHuQ53whsCv6aHWAEO4kmheKoUmT6NcMFQk8=; b=tBa5S6qgJPMfQji1BKArl/sHg6QafQ4/M72sI8ADvYhH5oo3tclMzLH6rBeKG8LvlFBkk7 rWq1NJfqAbifKtBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013952; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RVHkl1+gHuQ53whsCv6aHWAEO4kmheKoUmT6NcMFQk8=; b=ivM6DKJs1P3DuZSF49BpG/yJgOD2iNx/FqYl3LvsBHyKLY5Ip61zcX2+1TRAXlOPDYNGaX BDgznYgyw/xi2RO8rM82lLUVUNFgT+dmlrXub5hHuopaU1o8jLJ0UeSqAYwR1i0Ly9SXC1 4RY5vuVejVWVg9PNASye5f4ccbiEqsY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013952; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RVHkl1+gHuQ53whsCv6aHWAEO4kmheKoUmT6NcMFQk8=; b=P9DV6BFzaaTJWu8APoiVZGo2KFRYMIwg9TaZUrvUhIFKdQhxLE3zDaaHywnZnQY7+U8/JK wS52Zn79txWfhGBw== 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 16B8713946; Thu, 11 Jan 2024 22:59:11 +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 CWQzM79yoGV7LwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:59:11 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:15 -0300 Message-ID: <20240111225816.18117-10-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ivM6DKJs; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=P9DV6BFz X-Spamd-Result: default: False [4.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_RATELIMIT(0.00)[to_ip_from(RLsauj8dn5fwzrhashi71pkysg)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[12.46%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 8CA181FB69 X-Spamd-Bar: ++++ X-Headers-End: 1rO41E-0005yq-GY Subject: [f2fs-dev] [PATCH v3 09/10] ubifs: Configure dentry operations at dentry-creation time X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net fscrypt now supports configuring dentry operations at dentry-creation time through the preset sb->s_d_op, instead of at lookup time. Enable this in ubifs, since the lookup-time mechanism is going away. Signed-off-by: Gabriel Krisman Bertazi --- fs/ubifs/dir.c | 1 - fs/ubifs/super.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 3b13c648d490..51b9a10a9851 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -205,7 +205,6 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry, dbg_gen("'%pd' in dir ino %lu", dentry, dir->i_ino); err = fscrypt_prepare_lookup(dir, dentry, &nm); - generic_set_encrypted_ci_d_ops(dentry); if (err == -ENOENT) return d_splice_alias(NULL, dentry); if (err) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 09e270d6ed02..304646b03e99 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -2239,6 +2239,7 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) goto out_umount; } + generic_set_sb_d_ops(sb); sb->s_root = d_make_root(root); if (!sb->s_root) { err = -ENOMEM; From patchwork Thu Jan 11 22:58:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 13517840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E330EC47258 for ; Thu, 11 Jan 2024 22:59:28 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rO41I-0001tp-7T; Thu, 11 Jan 2024 22:59:28 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rO41G-0001tQ-31 for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=krPNAWpEhdO9kMaWrWqIUhp9mxXxNNl19QSIc2wCsrs=; b=dC5MQkZPOq/XfOPejSYw43FA4g MrzwdHQ+Kojp8HMgPUKy9f2T/IMc0sJitaSXZSYU81uk9Xm4DHUrnYJW45fV3t8A0wuPJ/NrLdogk syNnppAJiLmGlyIsQZsbWxDWs4FFnxzCmj33551+e+2XDyuwz7LO5uDSzVfqi1RTLP0M=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=krPNAWpEhdO9kMaWrWqIUhp9mxXxNNl19QSIc2wCsrs=; b=FLtqowOOUSjWn43gXR69mfbJsX ZkaMwuVDne7FYIMCvXAxwsKfoZl4KrdxWJlmtlH7Z9Y6jh24KQfki6XcTM9NwEy1xI9uv6cBw10eJ JAj8m2PsSa/MM/JZ/vykOaJgeW7W4mrV/qABuPvRER0OLAVb5fohJ60/4fUl6pV4TSa4=; Received: from smtp-out1.suse.de ([195.135.223.130]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1rO41B-0005yV-MH for linux-f2fs-devel@lists.sourceforge.net; Thu, 11 Jan 2024 22:59:26 +0000 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 BCE932224D; Thu, 11 Jan 2024 22:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013955; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=krPNAWpEhdO9kMaWrWqIUhp9mxXxNNl19QSIc2wCsrs=; b=WcFNgjj/j18Ww48IbCgHqwwfcEOz8PjCwYlTi38LI9E6WR4pEW58QHtPWWkNnFQ2786Ye0 YYUIhroZx7jHTT0jt4QH18/K8oDi8FIOdfCss1jYAY8LNOem0nNTDb5M50MiVU8HSCQS5v Q+uqxy+1O9yT5mZ8aE0Ggx4QVDELVhs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013955; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=krPNAWpEhdO9kMaWrWqIUhp9mxXxNNl19QSIc2wCsrs=; b=eJoenAAPc87+EMezQPd1TW8LiD2FPHgttszfN4mNiIu4OwptlcFT/dYuMhGBvVW6MZDp01 8BDRg4DrOBNAIUBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705013955; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=krPNAWpEhdO9kMaWrWqIUhp9mxXxNNl19QSIc2wCsrs=; b=WcFNgjj/j18Ww48IbCgHqwwfcEOz8PjCwYlTi38LI9E6WR4pEW58QHtPWWkNnFQ2786Ye0 YYUIhroZx7jHTT0jt4QH18/K8oDi8FIOdfCss1jYAY8LNOem0nNTDb5M50MiVU8HSCQS5v Q+uqxy+1O9yT5mZ8aE0Ggx4QVDELVhs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705013955; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=krPNAWpEhdO9kMaWrWqIUhp9mxXxNNl19QSIc2wCsrs=; b=eJoenAAPc87+EMezQPd1TW8LiD2FPHgttszfN4mNiIu4OwptlcFT/dYuMhGBvVW6MZDp01 8BDRg4DrOBNAIUBw== 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 3EC7113946; Thu, 11 Jan 2024 22:59:15 +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 0FjwAcNyoGV9LwAAD6G6ig (envelope-from ); Thu, 11 Jan 2024 22:59:15 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Date: Thu, 11 Jan 2024 19:58:16 -0300 Message-ID: <20240111225816.18117-11-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111225816.18117-1-krisman@suse.de> References: <20240111225816.18117-1-krisman@suse.de> MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [3.70 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_RATELIMIT(0.00)[to_ip_from(RLzk7q5dcbbphp39zi8hi5jhbt)]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[9]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[lists.sourceforge.net,vger.kernel.org,gmail.com,suse.de]; RCVD_TLS_ALL(0.00)[] X-Headers-End: 1rO41B-0005yV-MH Subject: [f2fs-dev] [PATCH v3 10/10] libfs: Drop generic_set_encrypted_ci_d_ops X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , linux-ext4@vger.kernel.org, amir73il@gmail.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net No filesystems depend on it anymore, and it is generally a bad idea. Since all dentries should have the same set of dentry operations in case-insensitive filesystems, it should be propagated through ->s_d_op. Signed-off-by: Gabriel Krisman Bertazi --- fs/libfs.c | 34 ---------------------------------- include/linux/fs.h | 1 - 2 files changed, 35 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 9cd4df6969d2..c5c92ac76ba7 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1788,40 +1788,6 @@ static const struct dentry_operations generic_encrypted_dentry_ops = { }; #endif -/** - * generic_set_encrypted_ci_d_ops - helper for setting d_ops for given dentry - * @dentry: dentry to set ops on - * - * Casefolded directories need d_hash and d_compare set, so that the dentries - * contained in them are handled case-insensitively. Note that these operations - * are needed on the parent directory rather than on the dentries in it, and - * while the casefolding flag can be toggled on and off on an empty directory, - * dentry_operations can't be changed later. As a result, if the filesystem has - * casefolding support enabled at all, we have to give all dentries the - * casefolding operations even if their inode doesn't have the casefolding flag - * currently (and thus the casefolding ops would be no-ops for now). - * - * Encryption works differently in that the only dentry operation it needs is - * d_revalidate, which it only needs on dentries that have the no-key name flag. - * The no-key flag can't be set "later", so we don't have to worry about that. - */ -void generic_set_encrypted_ci_d_ops(struct dentry *dentry) -{ -#if IS_ENABLED(CONFIG_UNICODE) - if (dentry->d_sb->s_encoding) { - d_set_d_op(dentry, &generic_ci_dentry_ops); - return; - } -#endif -#ifdef CONFIG_FS_ENCRYPTION - if (dentry->d_flags & DCACHE_NOKEY_NAME) { - d_set_d_op(dentry, &generic_encrypted_dentry_ops); - return; - } -#endif -} -EXPORT_SYMBOL(generic_set_encrypted_ci_d_ops); - /** * generic_set_sb_d_ops - helper for choosing the set of * filesystem-wide dentry operations for the enabled features diff --git a/include/linux/fs.h b/include/linux/fs.h index c985d9392b61..c0cfc53f95bb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3201,7 +3201,6 @@ extern int generic_file_fsync(struct file *, loff_t, loff_t, int); extern int generic_check_addressable(unsigned, u64); -extern void generic_set_encrypted_ci_d_ops(struct dentry *dentry); extern void generic_set_sb_d_ops(struct super_block *sb); static inline bool sb_has_encoding(const struct super_block *sb)