From patchwork Thu Sep 5 19:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792877 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D624ACE7A81 for ; Thu, 5 Sep 2024 19:03:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C6C86B0092; Thu, 5 Sep 2024 15:03:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 675DC6B0093; Thu, 5 Sep 2024 15:03:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F96B6B0095; Thu, 5 Sep 2024 15:03:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2DC906B0092 for ; Thu, 5 Sep 2024 15:03:40 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CDA651C2D4E for ; Thu, 5 Sep 2024 19:03:39 +0000 (UTC) X-FDA: 82531608558.14.810B7AC Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf19.hostedemail.com (Postfix) with ESMTP id 26EB21A000F for ; Thu, 5 Sep 2024 19:03:37 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ZJghaA+j; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf19.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562946; a=rsa-sha256; cv=none; b=YfGn3/gCS4NJG2Ex4JezifaBihIfchqxFVfmmHvU6fH9ObXG8CANcLyzQWhyroZ9CV/SJY 84GaLQJNux1f/Da7G324EztXA7SHya5Ttgs9dVti1wwU3hRBni0wbRaK/+jXmIdxINSHVH 5GUSarQYVVbtNIqeoNKEqoOMY28UvVM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ZJghaA+j; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf19.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562946; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=09RjlXQlRYkuU224DyyX5hGaeh4dLRLLtcX5SDFSDN0=; b=HBX3JXWolwjrLlh7L/BceIfRpe9jzP2aBNgSWVQ1VxgMq+coJwIHXHmGDwkn2hdR5nFOuh qDGB/DzYw8fAKEUF0iOgfWuZgM1V1bXnsILZgch3sReI0v3N/zF8h3KTHN/ihgvPrKYpMK 8nrHWwXGnvvA2OgiFwBQEC92ID0jbDw= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: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=09RjlXQlRYkuU224DyyX5hGaeh4dLRLLtcX5SDFSDN0=; b=ZJghaA+jVI7xvLO2YziWNskShX 87LUA2XkYooq3bZPKGSoYD5tloKq2MclVlntxHJslHNDeKX/iD/K2kgu3XG7t2uqpuHvYQ0ucO82U LliHgq6agb62p0rfBYgMSPxhhwOTW6v/7KOkaSsEmJFamtab29QMCgkORcdXuppFWpcbUr3ki8Faq MblpxRe1NSTRhC6GFxx9xyELWpjdG16psWeoWC4JtoP6doz7bx64aS4/xnZ9/DEz2FHllQXWu0jO1 9WobnQ1AolJBMzYeNRqaF0n5lurCWqveZ7dkrpjdjG93mPG8t6rhDDb+6oDgo6UY8LOENg1igrvzP y+ybT0cw==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHlS-00A6Ho-0W; Thu, 05 Sep 2024 21:03:29 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v3 5/9] libfs: Create the helper struct generic_ci_always_del_dentry_ops Date: Thu, 5 Sep 2024 16:02:48 -0300 Message-ID: <20240905190252.461639-6-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 26EB21A000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: p3j4718us9j9i3sumy7fcsz57dppy6ww X-HE-Tag: 1725563017-857073 X-HE-Meta: U2FsdGVkX1/+vhI7VW6paccf3uX6WbdO+cwA3RNWiVul4ksrp9ALt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ExyqRDlbIaotoutDVE4E2x3qTlQIKM7/dUQHVGoFioYRaqzYsbC0RlXF8zrWnfV8XMQc1X/GCvpc45lK5AdDLDc7B67Aboh7aVdQOG61M/I/QxWtJBQ+5Ko1oBoH52RyZTW1Ww0A/1vM+xO/+bYNOIVXy7AcM65HA4dOLl4m5z/400d1jEqK05OC/IEigkT5d4RNYbVhJwhhTjk6DflnbR2Df7XCmPX+MxWRIZXcdzd1gIXY9SsJHEs21qhhzu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Create a helper to assign dentry_operations with the generic case insensitive functions plus setting .d_delete as always_delete_dentry. This is useful to in-memory casefold filesystems like tmpfs. Signed-off-by: André Almeida --- v3: New patch --- fs/libfs.c | 15 +++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 16 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 99fb36b48708..58b39640b686 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1855,6 +1855,21 @@ static const struct dentry_operations generic_ci_dentry_ops = { #endif }; +/* + * Same as generic_ci_dentry_ops, but also set d_delete. Useful for in-memory + * casefold filesystems. + */ +const struct dentry_operations generic_ci_always_del_dentry_ops = { + .d_hash = generic_ci_d_hash, + .d_compare = generic_ci_d_compare, +#ifdef CONFIG_FS_ENCRYPTION + .d_revalidate = fscrypt_d_revalidate, +#endif + .d_delete = always_delete_dentry, +}; +EXPORT_SYMBOL(generic_ci_always_del_dentry_ops); + + /** * generic_ci_match() - Match a name (case-insensitively) with a dirent. * This is a filesystem helper for comparison with directory entries. diff --git a/include/linux/fs.h b/include/linux/fs.h index 937142950dfe..254a1dcf987b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3337,6 +3337,7 @@ extern int always_delete_dentry(const struct dentry *); extern struct inode *alloc_anon_inode(struct super_block *); extern int simple_nosetlease(struct file *, int, struct file_lease **, void **); extern const struct dentry_operations simple_dentry_operations; +extern const struct dentry_operations generic_ci_always_del_dentry_ops; extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);