Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2805715rdb; Mon, 12 Feb 2024 18:29:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7N0ovI32zmzfoPB6iD0qRvxJpgaPtVZQTzPmJSrCcmgU3z2eH8qnk7zfPKAKU/nYVXtcx X-Received: by 2002:a17:903:32d1:b0:1d9:6cb4:3330 with SMTP id i17-20020a17090332d100b001d96cb43330mr11228547plr.12.1707791386933; Mon, 12 Feb 2024 18:29:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707791386; cv=pass; d=google.com; s=arc-20160816; b=ZA19kXarMzUrO0U/D7r8lr4y+znMjXb9jRYX6SGBxCiYQSkINwSi96Gj6I3RD+6qHb LdgzJofq2ySSyMuASyT7ZKGumJZvjenKl4UCnZAFBDcjnraLmB5Dt1K1nKoT93K3wzr9 RqM4YlWWhYfUHHrr40HbUPfHgY6llj2xqwp3bHBAWlQNpqtk30CEsht/2zL0kEoIDqgC 5ogdpB8NXdlpO9FE42i+8MqUGJgZF3AaYIstMN7/m5Waf8A/r2fcML6kylbnuqaCFdXW iaV4LTDouLHoTzM0fgg35TzFIPnlLGki9Z49IbT9UwwFVa9/LgB6hej8yQ2/uoq3Emkh 7NDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=S7ZNiObuWDS9LBRJ78fuLAlJGd+uQndWdyw51G7pKEU=; fh=zOGjYlE3HsL0pr0TrJkr5UCHCSaYs6LybYhCdeyONq4=; b=DTNlifWxvarCCTBXhIg5hWvzP6P23ABB4fn6zSCTLcq2ze3znjYnjhCNO39R7rFzQw 9F/b+LQqYlPjLcSTwlooCGlhlC/QB5HuUeh8aSGBmTic15I1C8qolovwRA0sFDNP797e cd1X/nzAUhrCGnKNas1t4GkQgZq9mTpjH/hJ9gYsZTRLe5D6AuqUds4C8U/WRVgFEqEu 6+E10IMbX3qeVrzDQD8K7Th0NZkGGa760N3gXimZTBMyf2np6ZR3rhhy+RiJuHgpqP/S ygNvKaM14JuJUG6JqcHy6cPYWDhmHlVo+nfPwmzKhj8EGVpGnT+7XdH2mMlm2GzL7BzY Em3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PbT+blzW; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PbT+blzW; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-1210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1210-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=2; AJvYcCWO8/q9EwylAYKYZrwp/FNKvTvCo/DOHhc/gPbDRb0pe/bSYkBrJ3DHRBTlEu5nltyXtSQxZsO+BptKghMTHoemmvf1ddz8p67ntXK87A== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q7-20020a170902dac700b001d6f61e84bcsi1228406plx.454.2024.02.12.18.29.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 18:29:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PbT+blzW; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PbT+blzW; dkim=neutral (no key) header.i=@suse.de; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-1210-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1210-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 91D84B222E0 for ; Tue, 13 Feb 2024 02:14:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AFCC8473; Tue, 13 Feb 2024 02:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PbT+blzW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="NOxu7is7"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PbT+blzW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="NOxu7is7" 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 8A5E479EF; Tue, 13 Feb 2024 02:13:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707790436; cv=none; b=i0tiEAnCCf6v4jyPiiqDIaS6CaNWgtCupqDrkGMLcMzdld1V0NWflp4ML73gi7JS7gz1LYZ5cikQ8UkKwKQkxYZWjsReGvujJbUM/A8ZngliZPWYJNDCyjddmvba7S/pkedI9cTqUBJSAq6gP3p1nfg+ykqemIe+bvgebfuVhPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707790436; c=relaxed/simple; bh=8KvF2pTb3E+igBwE1A5eAT6de1YY3lOPRIH1gV1BZRM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LW3AP7xyhHlpVAxKkyxN3qvHbZ8HEwtN5MZ1W1IC62hpP6of/RAIIlYLOYXMxLOQUkosKfzCa59MjdtE3x9k1WQQnd3THP5+nYYFC/X+PP8BunBpgj8chUO1pGuviO/AaX/rqwg08MJgeFfsLA6KFyaRoV3DKXgAgv3IBoSrQWM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=PbT+blzW; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=NOxu7is7; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=PbT+blzW; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=NOxu7is7; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CA0801F79E; Tue, 13 Feb 2024 02:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707790432; 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=S7ZNiObuWDS9LBRJ78fuLAlJGd+uQndWdyw51G7pKEU=; b=PbT+blzWubIhYUPFhtKbJRqtV/EPxWmE2kFMSlEGJ5/+efTXPk+aJ1LHSDjPZSarY9DbIo L9hVUi2WDErRnAxTXBp13lePo+R0hM+P6pec9s2W8g040jglzn4NUngNW9U+NFdDQRj52z dZ3MzR+vg7m1R/cdQY0RQyORXF2U8Ak= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707790432; 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=S7ZNiObuWDS9LBRJ78fuLAlJGd+uQndWdyw51G7pKEU=; b=NOxu7is7pKLIwFir01xzC5Pt18/K6WG6ypnzRi4qGpIvWenw+G3yJQXIIbGwlcq8kcI8d5 JisjyYmZHr2h6WBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707790432; 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=S7ZNiObuWDS9LBRJ78fuLAlJGd+uQndWdyw51G7pKEU=; b=PbT+blzWubIhYUPFhtKbJRqtV/EPxWmE2kFMSlEGJ5/+efTXPk+aJ1LHSDjPZSarY9DbIo L9hVUi2WDErRnAxTXBp13lePo+R0hM+P6pec9s2W8g040jglzn4NUngNW9U+NFdDQRj52z dZ3MzR+vg7m1R/cdQY0RQyORXF2U8Ak= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707790432; 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=S7ZNiObuWDS9LBRJ78fuLAlJGd+uQndWdyw51G7pKEU=; b=NOxu7is7pKLIwFir01xzC5Pt18/K6WG6ypnzRi4qGpIvWenw+G3yJQXIIbGwlcq8kcI8d5 JisjyYmZHr2h6WBQ== 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 92F3113A4B; Tue, 13 Feb 2024 02:13: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 oZuWHWDQymUieAAAD6G6ig (envelope-from ); Tue, 13 Feb 2024 02:13:52 +0000 From: Gabriel Krisman Bertazi To: ebiggers@kernel.org, viro@zeniv.linux.org.uk Cc: jaegeuk@kernel.org, tytso@mit.edu, amir73il@gmail.com, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, brauner@kernel.org, Gabriel Krisman Bertazi Subject: [PATCH v6 06/10] libfs: Add helper to choose dentry operations at mount-time Date: Mon, 12 Feb 2024 21:13:17 -0500 Message-ID: <20240213021321.1804-7-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213021321.1804-1-krisman@suse.de> References: <20240213021321.1804-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=PbT+blzW; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=NOxu7is7 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)[]; R_RATELIMIT(0.00)[to_ip_from(RLsauj8dn5fwzrhashi71pkysg)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[10]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[18.33%]; 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)[kernel.org,mit.edu,gmail.com,vger.kernel.org,lists.sourceforge.net,suse.de]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: 3.49 X-Rspamd-Queue-Id: CA0801F79E 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 --- changes since v3: - Fix typo in comment (Eric) --- fs/libfs.c | 28 ++++++++++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 29 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index c4be0961faf0..0aa388ee82ff 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1822,6 +1822,34 @@ 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_op 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