From: Eric Biggers <ebiggers@kernel.org>
To: Gabriel Krisman Bertazi <krisman@collabora.com>
Cc: tytso@mit.edu, jaegeuk@kernel.org, linux-ext4@vger.kernel.org,
kernel@collabora.com
Subject: Re: [PATCH 1/5] ext4: Match the f2fs ci_compare implementation
Date: Mon, 28 Mar 2022 19:58:14 -0700 [thread overview]
Message-ID: <YkJ1xmB1wXQ1WCJ7@sol.localdomain> (raw)
In-Reply-To: <20220322030004.148560-2-krisman@collabora.com>
On Mon, Mar 21, 2022 at 11:00:00PM -0400, Gabriel Krisman Bertazi wrote:
> ext4_ci_compare originally follows utf8_*_strcmp, which means return
> zero on match. This means that every usage of that in ext4 negates
> the return.
>
> Turn it into a predicate function, let it follow the kernel convention
> and return true on match, which means it's now the same as its f2fs
> counterpart and can be extracted into generic code.
>
> This change also makes it more obvious that we are ignoring error
> handling in ext4_match, which can occur since casefolding support (bad
> utf8 name due to disk corruption on strict mode causes -EINVAL) and
> casefold+encryption (-ENOMEM). For now, keep the behavior. It is
> handled by the following patches.
>
> While we are there, change the comment to the kernel-doc style.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
> ---
> fs/ext4/namei.c | 62 +++++++++++++++++++++++++++++++++----------------
> 1 file changed, 42 insertions(+), 20 deletions(-)
>
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 8cf0a924a49b..24ea3bb446d0 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -1318,13 +1318,20 @@ static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block)
> }
>
> #if IS_ENABLED(CONFIG_UNICODE)
> -/*
> +/**
> + * ext4_ci_compare() - Match (case-insensitive) a name with a dirent.
> + * @parent: Inode of the parent of the dentry.
> + * @name: name under lookup.
> + * @de_name: Dirent name.
> + * @de_name_len: dirent name length.
> + * @quick: whether @name is already casefolded.
> + *
> * Test whether a case-insensitive directory entry matches the filename
> - * being searched for. If quick is set, assume the name being looked up
> - * is already in the casefolded form.
> + * being searched. If quick is set, the @name being looked up is
> + * already in the casefolded form.
> *
> - * Returns: 0 if the directory entry matches, more than 0 if it
> - * doesn't match or less than zero on error.
> + * Return: > 0 if the directory entry matches, 0 if it doesn't match, or
> + * < 0 on error.
> */
> static int ext4_ci_compare(const struct inode *parent, const struct qstr *name,
> u8 *de_name, size_t de_name_len, bool quick)
Shouldn't this be renamed to ext4_match_ci() as well? The f2fs equivalent is
called f2fs_match_ci_name(), and this is called from ext4_match().
ext4_match_ci() would better fit the "return 1 on match" behavior, I think.
- Eric
next prev parent reply other threads:[~2022-03-29 2:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-22 2:59 [PATCH 0/5] Clean up the case-insenstive lookup path Gabriel Krisman Bertazi
2022-03-22 3:00 ` [PATCH 1/5] ext4: Match the f2fs ci_compare implementation Gabriel Krisman Bertazi
2022-03-29 2:58 ` Eric Biggers [this message]
2022-03-22 3:00 ` [PATCH 2/5] ext4: Simplify the handling of chached insensitive names Gabriel Krisman Bertazi
2022-03-29 3:01 ` Eric Biggers
2022-03-22 3:00 ` [PATCH 3/5] ext4: Implement ci comparison using fscrypt_name Gabriel Krisman Bertazi
2022-03-29 3:08 ` Eric Biggers
2022-03-29 16:11 ` Gabriel Krisman Bertazi
2022-03-31 21:43 ` Eric Biggers
2022-04-04 19:59 ` Gabriel Krisman Bertazi
2022-03-22 3:00 ` [PATCH 4/5] ext4: Simplify hash check on ext4_match Gabriel Krisman Bertazi
2022-03-22 3:00 ` [PATCH 5/5] ext4: Log error when lookup of encoded dentry fails Gabriel Krisman Bertazi
2022-03-29 3:21 ` Eric Biggers
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=YkJ1xmB1wXQ1WCJ7@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=kernel@collabora.com \
--cc=krisman@collabora.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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