Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1189393rdb; Fri, 19 Jan 2024 10:49:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7Dgo/t/6wM+kzlUnwhi4U1bli7wjVmSWR55K97GvX0lUJpSnPjLpLIM1FN1H3gC9Lkji2 X-Received: by 2002:a05:600c:4612:b0:40c:3d91:152 with SMTP id m18-20020a05600c461200b0040c3d910152mr137474wmo.79.1705690147118; Fri, 19 Jan 2024 10:49:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705690147; cv=pass; d=google.com; s=arc-20160816; b=v0ThyXXfpgwC6Ma1DRG8nIVy7tWjk0wVhDRTbDs1GlK4SGac0htM8oCkTaYAnE0UkH zJxyazBPW9qAg8ny1suIZJn2wqas9PNGbXaRYfw7Tm5ptkUlpg5wbyO7sgpCpUINQa2b mPgu/RCMz1cJ5g3WVuqx3f6Q7xgcESToxiDUt5Qm4kNb7377iUBvQ5sVeKqXFYLW3/Oc ToAD2O5/SHaK8ZdcqMY0rYUCFsmyfQEk5WaBtdeTVgjIdPyH2MABJGbHBmvs+n5JmKF6 sbY/DxnrG+LIsPceBxTufXigME2Pn52i2kn1tddQCi+GdvZzl49oXza9DM8IPpW/nW7A 4MAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=7n1vpYH9zMkx8GCAKMQ38/U0hkGRlRzMkf9u51OH3zI=; fh=TR5Gg30v3tsunp9zlnj9BCAk32Yv/gHGLFfg9mPqX30=; b=NXTfxG2E5Ej+VceOs1vrwgAKzjNW2BA77tKkS2scTaJDDlN4TQ4u0W3Kk+7BXFD16g hVdHSrhkjymF5lD86J9MCe9fob98B2blXwE4a/skmDs57920Vly9KUmOvnDjftogB1lC pQq60DjnYOoKnjo8A8PcalIbuYFsAzAywUjSFcMh30GGauvWgkqODVc7SJ7Gk654FQey byCbx8mpGC5M2g6rR+19pd3TuCgsDQg9J5S5petb9qN2o7uiW6/w9kRzgut/36gCsdps eFOFtMjCSjLCw2RvIR6iAjm000huS0qWgGF/o06wNk+Mk60Ptp9Tqicb1rfyjukLFWGV EBNw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lb10-20020a170906adca00b00a2a2307cee2si8049316ejb.363.2024.01.19.10.49.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 10:49:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-ext4+bounces-858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DC6891F263F7 for ; Fri, 19 Jan 2024 18:49:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4530356B6D; Fri, 19 Jan 2024 18:48:29 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 946F15466D; Fri, 19 Jan 2024 18:48:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705690109; cv=none; b=RvyYkNc2rS2dH+1w0umDoMb2VUSmJDI1gZovg95t3xn9CIIVMAyQIwlSBokuzWRXz7QywnWdfDU2HBfXtN9yUeS/ospi9Ul5Dc3qTGINAddfZkYb8wvwhj2ieYFoqf9sWKPsaZBdj8inc0hTjerBMp0ZzuAE9uyrYwg2h2Mcaf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705690109; c=relaxed/simple; bh=jTQzVAQbekjjjFME540Hi7+OHVn9Jfy9f2r/b+9lbHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XZkwuBReM2BwcvjQlkbvVKpqgCc8d7pbgwWI+Kw54itT7i7DMXaJcOod9NN3QqKXSB+yCDI0f9j4LOUsgY5BgNlijcuKBcu9vNYTx+f2LkZp1sJB2/qJhwCOjvBachkFiTaEBamubIYA2nJX6B4WFZex8Z5BZS1GDR17wj0ro3k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 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-out1.suse.de (Postfix) with ESMTPS id D893A21FB3; Fri, 19 Jan 2024 18:48:25 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 51910136F5; Fri, 19 Jan 2024 18:48:25 +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 8em3A/nDqmVfDAAAD6G6ig (envelope-from ); Fri, 19 Jan 2024 18:48:25 +0000 From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, ebiggers@kernel.org, jaegeuk@kernel.org, tytso@mit.edu Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, 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: Fri, 19 Jan 2024 15:47:38 -0300 Message-ID: <20240119184742.31088-7-krisman@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240119184742.31088-1-krisman@suse.de> References: <20240119184742.31088-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: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: D893A21FB3 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