From: Gabriel Krisman Bertazi <krisman@suse.de>
To: ebiggers@kernel.org, viro@zeniv.linux.org.uk,
torvalds@linux-foundation.org
Cc: tytso@mit.edu, linux-fsdevel@vger.kernel.org, jaegeuk@kernel.org,
Gabriel Krisman Bertazi <krisman@suse.de>
Subject: [PATCH v3 1/2] dcache: Expose dentry_string_cmp outside of dcache
Date: Fri, 19 Jan 2024 17:25:42 -0300 [thread overview]
Message-ID: <20240119202544.19434-2-krisman@suse.de> (raw)
In-Reply-To: <20240119202544.19434-1-krisman@suse.de>
In preparation to call these from libfs, expose dentry_string_cmp in the
header file.
Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de>
---
fs/dcache.c | 53 ------------------------------------------
include/linux/dcache.h | 53 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index b813528fb147..7bb17596d0ad 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -201,59 +201,6 @@ static int __init init_fs_dcache_sysctls(void)
fs_initcall(init_fs_dcache_sysctls);
#endif
-/*
- * Compare 2 name strings, return 0 if they match, otherwise non-zero.
- * The strings are both count bytes long, and count is non-zero.
- */
-#ifdef CONFIG_DCACHE_WORD_ACCESS
-
-#include <asm/word-at-a-time.h>
-/*
- * NOTE! 'cs' and 'scount' come from a dentry, so it has a
- * aligned allocation for this particular component. We don't
- * strictly need the load_unaligned_zeropad() safety, but it
- * doesn't hurt either.
- *
- * In contrast, 'ct' and 'tcount' can be from a pathname, and do
- * need the careful unaligned handling.
- */
-static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char *ct, unsigned tcount)
-{
- unsigned long a,b,mask;
-
- for (;;) {
- a = read_word_at_a_time(cs);
- b = load_unaligned_zeropad(ct);
- if (tcount < sizeof(unsigned long))
- break;
- if (unlikely(a != b))
- return 1;
- cs += sizeof(unsigned long);
- ct += sizeof(unsigned long);
- tcount -= sizeof(unsigned long);
- if (!tcount)
- return 0;
- }
- mask = bytemask_from_count(tcount);
- return unlikely(!!((a ^ b) & mask));
-}
-
-#else
-
-static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char *ct, unsigned tcount)
-{
- do {
- if (*cs != *ct)
- return 1;
- cs++;
- ct++;
- tcount--;
- } while (tcount);
- return 0;
-}
-
-#endif
-
static inline int dentry_cmp(const struct dentry *dentry, const unsigned char *ct, unsigned tcount)
{
/*
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 1666c387861f..0f210a396074 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -592,4 +592,57 @@ static inline struct dentry *d_next_sibling(const struct dentry *dentry)
return hlist_entry_safe(dentry->d_sib.next, struct dentry, d_sib);
}
+/*
+ * Compare 2 name strings, return 0 if they match, otherwise non-zero.
+ * The strings are both count bytes long, and count is non-zero.
+ */
+#ifdef CONFIG_DCACHE_WORD_ACCESS
+
+#include <asm/word-at-a-time.h>
+/*
+ * NOTE! 'cs' and 'scount' come from a dentry, so it has a
+ * aligned allocation for this particular component. We don't
+ * strictly need the load_unaligned_zeropad() safety, but it
+ * doesn't hurt either.
+ *
+ * In contrast, 'ct' and 'tcount' can be from a pathname, and do
+ * need the careful unaligned handling.
+ */
+static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char *ct, unsigned tcount)
+{
+ unsigned long a,b,mask;
+
+ for (;;) {
+ a = read_word_at_a_time(cs);
+ b = load_unaligned_zeropad(ct);
+ if (tcount < sizeof(unsigned long))
+ break;
+ if (unlikely(a != b))
+ return 1;
+ cs += sizeof(unsigned long);
+ ct += sizeof(unsigned long);
+ tcount -= sizeof(unsigned long);
+ if (!tcount)
+ return 0;
+ }
+ mask = bytemask_from_count(tcount);
+ return unlikely(!!((a ^ b) & mask));
+}
+
+#else
+
+static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char *ct, unsigned tcount)
+{
+ do {
+ if (*cs != *ct)
+ return 1;
+ cs++;
+ ct++;
+ tcount--;
+ } while (tcount);
+ return 0;
+}
+
+#endif
+
#endif /* __LINUX_DCACHE_H */
--
2.43.0
next prev parent reply other threads:[~2024-01-19 20:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 20:25 [PATCH v3 0/2] Try exact-match comparison ahead of case-insensitive match Gabriel Krisman Bertazi
2024-01-19 20:25 ` Gabriel Krisman Bertazi [this message]
2024-01-19 20:48 ` [PATCH v3 1/2] dcache: Expose dentry_string_cmp outside of dcache Linus Torvalds
2024-01-21 16:34 ` Gabriel Krisman Bertazi
2024-01-21 19:09 ` Linus Torvalds
2024-01-24 18:13 ` [PATCH v4] libfs: Attempt exact-match comparison first during casefolded lookup Gabriel Krisman Bertazi
2024-01-24 18:42 ` Linus Torvalds
2024-01-24 22:44 ` Eric Biggers
2024-01-19 20:25 ` [PATCH v3 2/2] libfs: Attempt exact-match comparison first during casefold lookup Gabriel Krisman Bertazi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240119202544.19434-2-krisman@suse.de \
--to=krisman@suse.de \
--cc=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).