[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200708041230.GL839@sol.localdomain>
Date: Tue, 7 Jul 2020 21:12:30 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: Daniel Rosenberg <drosen@...gle.com>
Cc: Theodore Ts'o <tytso@....edu>, linux-ext4@...r.kernel.org,
Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>,
linux-f2fs-devel@...ts.sourceforge.net,
linux-fscrypt@...r.kernel.org,
Alexander Viro <viro@...iv.linux.org.uk>,
Andreas Dilger <adilger.kernel@...ger.ca>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Gabriel Krisman Bertazi <krisman@...labora.com>,
kernel-team@...roid.com
Subject: Re: [PATCH v11 2/4] fs: Add standard casefolding support
On Tue, Jul 07, 2020 at 08:05:50PM -0700, Daniel Rosenberg wrote:
> +/**
> + * generic_ci_d_compare - generic d_compare implementation for casefolding filesystems
> + * @dentry: dentry whose name we are checking against
> + * @len: len of name of dentry
> + * @str: str pointer to name of dentry
> + * @name: Name to compare against
> + *
> + * Return: 0 if names match, 1 if mismatch, or -ERRNO
> + */
> +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len,
> + const char *str, const struct qstr *name)
> +{
> + const struct dentry *parent = READ_ONCE(dentry->d_parent);
> + const struct inode *inode = READ_ONCE(parent->d_inode);
How about calling the 'inode' variable 'dir' instead?
That would help avoid confusion about what is the directory and what is a file
in the directory.
Likewise in generic_ci_d_hash().
> +/**
> + * generic_ci_d_hash - generic d_hash implementation for casefolding filesystems
> + * @dentry: dentry whose name we are hashing
This comment for @dentry needs to be updated.
It's the parent dentry, not the dentry whose name we are hashing.
> + * @str: qstr of name whose hash we should fill in
> + *
> + * Return: 0 if hash was successful, or -ERRNO
As I mentioned on v9, this can also return 0 if the hashing was not done because
it wants to fallback to the standard hashing. Can you please fix the comment?
> +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str)
> +{
> + const struct inode *inode = READ_ONCE(dentry->d_inode);
> + struct super_block *sb = dentry->d_sb;
> + const struct unicode_map *um = sb->s_encoding;
> + int ret = 0;
> +
> + if (!inode || !needs_casefold(inode))
> + return 0;
> +
> + ret = utf8_casefold_hash(um, dentry, str);
> + if (ret < 0)
> + goto err;
> +
> + return 0;
> +err:
> + if (sb_has_strict_encoding(sb))
> + ret = -EINVAL;
> + else
> + ret = 0;
> + return ret;
> +}
On v9, Gabriel suggested simplifying this to:
ret = utf8_casefold_hash(um, dentry, str);
if (ret < 0 && sb_has_enc_strict_mode(sb))
return -EINVAL;
return 0;
Any reason not to do that?
- Eric
Powered by blists - more mailing lists