Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1956943rdd; Thu, 11 Jan 2024 14:59:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYhBjO3BOADcVEyU9ONjw+sv3qCI7/Yn6VNGXgb8UTfhO5EV58TFUM5uWARbrkpCv22q0b X-Received: by 2002:a17:90a:8b06:b0:28c:74e:bbd9 with SMTP id y6-20020a17090a8b0600b0028c074ebbd9mr560557pjn.18.1705013970310; Thu, 11 Jan 2024 14:59:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705013970; cv=none; d=google.com; s=arc-20160816; b=ofp72MuEQzvbAfSpwU3x4KPpXalFysiEENCiTHpgQQwrZFHU/GqfW4Ywni6aDDaoEf XS0qFY4qg0s5abN4Qqpwwd+yP4RC14CCqfJB0caguhQx0/hFsI5pXXwVGqiXq7TBQBjg lksQWMzFVhofKbPBRPkYn0+XDYObcZD6oymGx7ArSAJJLfjmWaltxOdTedtN6gntYOYM eOM6jBvLiWrXwdrooVFwc9O1mKFQm/bQUsi9hHP550DXD3jr+KPlJJ7cgemYtdtKfJx6 oib6kHTmr09+BjGEJN4Bp0XY0+P7FuOJfn7y2D2M8WQE9FIlzyIEWO0bhyszXK2Aae0j BT/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=7n1vpYH9zMkx8GCAKMQ38/U0hkGRlRzMkf9u51OH3zI=; fh=txLUcZWR0Mn+AOInn8hb4p5ZPQWLqJuy4UySlPkPPxE=; b=ScyZ7u7Py6TthZ0VYtT/EKOfFCkN9XjOu/DNUpa2Gli5RFpYfdc3PYcK0eWPA7JCMw Tkk66XbSCVEEIqU7tEwsRnkzurDjpGFzhpAGjr2b1z+Xwzbu2mpArjabzFVGQ6mLP7bX 1VOEPY3VFyXb3fuxOHkbkP+76Pf5RCCO+FKnm752/cvEqTkYlNHsO2+DVsk/hQBEqjzk zVBQjxBoBFipDA+34qmfJcCGQnMgO7ThOs1WxwhEm9sHY6u2pC0Y1OF7NnOL9yv1DtQf /mlQ4MV84JuvOA8WJm/flvEs1mGR26HNGeAZzxqkAwJznPQvuB9a/mGH/po1ZAnqMiTD 7/4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mcr8BVPO; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mcr8BVPO; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-ext4+bounces-782-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-782-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id kb5-20020a17090ae7c500b0028bd7c613ddsi5003452pjb.34.2024.01.11.14.59.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 14:59:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-782-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mcr8BVPO; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mcr8BVPO; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-ext4+bounces-782-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-782-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id ED6DA288114 for ; Thu, 11 Jan 2024 22:59:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF5C859164; Thu, 11 Jan 2024 22:59:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mcr8BVPO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+kBhDoA/"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mcr8BVPO"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+kBhDoA/" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB0D23A1B7; Thu, 11 Jan 2024 22:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 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 Cc: linux-f2fs-devel@lists.sourceforge.net, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, amir73il@gmail.com, Gabriel Krisman Bertazi Subject: [PATCH v3 06/10] libfs: Add helper to choose dentry operations at mount 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> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Level: *** X-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-Spam-Score: 3.49 X-Rspamd-Queue-Id: 1862E1F74A X-Spam-Flag: NO 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) { -- 2.43.0