Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Weber, Olaf (HPC Data Management & Storage)" <olaf.weber@hpe.com>
To: Gabriel Krisman Bertazi <krisman@collabora.co.uk>,
	"tytso@mit.edu" <tytso@mit.edu>,
	"david@fromorbit.com" <david@fromorbit.com>,
	"bpm@sgi.com" <bpm@sgi.com>, "olaf@sgi.com" <olaf@sgi.com>
Cc: "linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"kernel@lists.collabora.co.uk" <kernel@lists.collabora.co.uk>,
	"alvaro.soliverez@collabora.co.uk"
	<alvaro.soliverez@collabora.co.uk>
Subject: RE: [PATCH RFC 13/13] ext4: Implement ext4 dcache hooks for custom charsets
Date: Fri, 12 Jan 2018 10:52:57 +0000	[thread overview]
Message-ID: <DF4PR8401MB0812FF0D5F50D89C14015C0485170@DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20180112071234.29470-14-krisman@collabora.co.uk>

Hi Gabriel,

Short summary: you're calling functions that can return an error, but do not check for that.

Olaf

> -----Original Message-----
> From: Gabriel Krisman Bertazi [mailto:krisman@collabora.co.uk]
> Sent: Friday, January 12, 2018 08:13
> To: tytso@mit.edu; david@fromorbit.com; bpm@sgi.com; olaf@sgi.com
> Cc: linux-ext4@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> kernel@lists.collabora.co.uk; alvaro.soliverez@collabora.co.uk; Gabriel
> Krisman Bertazi <krisman@collabora.co.uk>
> Subject: [PATCH RFC 13/13] ext4: Implement ext4 dcache hooks for custom
> charsets
> 
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk>
> ---
>  fs/ext4/dir.c   | 63
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  fs/ext4/ext4.h  |  2 ++
>  fs/ext4/super.c |  5 +++++
>  3 files changed, 70 insertions(+)
> 
> diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
> index d5babc9f222b..8b73a68930d2 100644
> --- a/fs/ext4/dir.c
> +++ b/fs/ext4/dir.c
> @@ -25,6 +25,7 @@
>  #include <linux/fs.h>
>  #include <linux/buffer_head.h>
>  #include <linux/slab.h>
> +#include <linux/charsets.h>
>  #include "ext4.h"
>  #include "xattr.h"
> 
> @@ -661,3 +662,65 @@ const struct file_operations ext4_dir_operations = {
>  	.open		= ext4_dir_open,
>  	.release	= ext4_release_dir,
>  };
> +
> +static int ext4_d_hash(const struct dentry *dentry, struct qstr *q)
> +{
> +	unsigned long hash;
> +	int i, len;
> +	char *str;
> +	const struct charset *charset = EXT4_SB(dentry->d_sb)->encoding;
> +
> +	len = charset_normalize(charset, q->name, q->len, &str);

What if charset_normalize() returns an error?


> +
> +	hash = init_name_hash(dentry);
> +	for (i = 0; i < len; i++)
> +		hash = partial_name_hash(str[i], hash);
> +	q->hash = end_name_hash(hash);
> +
> +	kfree(str);
> +	return 0;
> +}
> +
> +static int ext4_d_compare(const struct dentry *dentry, unsigned int len,
> +			  const char *str, const struct qstr *name)
> +{
> +	const struct charset *charset = EXT4_SB(dentry->d_sb)->encoding;
> +
> +	return charset_strncmp(charset, str, name->name, len);
> +}
> +
> +const struct dentry_operations ext4_dentry_ops = {
> +	.d_hash = ext4_d_hash,
> +	.d_compare = ext4_d_compare,
> +};
> +
> +static int ext4_d_ci_hash(const struct dentry *dentry, struct qstr *q)
> +{
> +	unsigned long hash;
> +	int i, len;
> +	char *str;
> +	const struct charset *charset = EXT4_SB(dentry->d_sb)->encoding;
> +
> +	len = charset_casefold(charset, q->name, q->len, &str);

What if charset_casefold() returns an error?


> +
> +	hash = init_name_hash(dentry);
> +	for (i = 0; i < len; i++)
> +		hash = partial_name_hash(str[i], hash);
> +	q->hash = end_name_hash(hash);
> +
> +	kfree(str);
> +	return 0;
> +}
> +
> +static int ext4_d_ci_compare(const struct dentry *dentry, unsigned int len,
> +			     const char *str, const struct qstr *name)
> +{
> +	const struct charset *charset = EXT4_SB(dentry->d_sb)->encoding;
> +
> +	return charset_strncasecmp(charset, str, name->name, len);
> +}
> +
> +const struct dentry_operations ext4_ci_dentry_ops = {
> +	.d_hash = ext4_d_ci_hash,
> +	.d_compare = ext4_d_ci_compare,
> +};
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 6c8aaf2dd322..980968aeb1cf 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -2943,6 +2943,8 @@ static inline void ext4_unlock_group(struct
> super_block *sb,
> 
>  /* dir.c */
>  extern const struct file_operations ext4_dir_operations;
> +extern const struct dentry_operations ext4_dentry_ops;
> +extern const struct dentry_operations ext4_ci_dentry_ops;
> 
>  /* file.c */
>  extern const struct inode_operations ext4_file_inode_operations;
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 022bf5f274b2..877acb938453 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -4358,6 +4358,11 @@ static int ext4_fill_super(struct super_block *sb,
> void *data, int silent)
>  	if (es->s_error_count)
>  		mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5
> minutes */
> 
> +	if (test_opt2(sb, CASE_INSENSITIVE))
> +		sb->s_d_op = &ext4_ci_dentry_ops;
> +	else
> +		sb->s_d_op = &ext4_dentry_ops;
> +
>  	/* Enable message ratelimiting. Default is 10 messages per 5 secs. */
>  	ratelimit_state_init(&sbi->s_err_ratelimit_state, 5 * HZ, 10);
>  	ratelimit_state_init(&sbi->s_warning_ratelimit_state, 5 * HZ, 10);
> --
> 2.15.1

  reply	other threads:[~2018-01-12 10:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-12  7:12 [PATCH RFC 00/13] UTF-8 case insensitive lookups for EXT4 Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 01/13] charsets: Introduce middle-layer for character encoding Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 02/13] charsets: ascii: Wrap ascii functions to charsets library Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 03/13] charsets: utf8: Add unicode character database files Gabriel Krisman Bertazi
2018-01-12 16:59   ` Darrick J. Wong
2018-01-12 20:29     ` Weber, Olaf (HPC Data Management & Storage)
2018-01-13  0:24   ` Theodore Ts'o
2018-01-13  4:28     ` Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 04/13] scripts: add trie generator for UTF-8 Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 05/13] charsets: utf8: Introduce code for UTF-8 normalization Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 06/13] charsets: utf8: reduce the size of utf8data[] Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 07/13] charsets: utf8: Hook-up utf-8 code to charsets library Gabriel Krisman Bertazi
2018-01-12 10:38   ` Weber, Olaf (HPC Data Management & Storage)
2018-01-16 16:50     ` Gabriel Krisman Bertazi
2018-01-16 22:19       ` Weber, Olaf (HPC Data Management & Storage)
2018-01-23  3:33         ` Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 08/13] charsets: utf8: Introduce test module for kernel UTF-8 implementation Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 09/13] ext4: Add ignorecase mount option Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 10/13] ext4: Include encoding information on the superblock Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 11/13] fscrypt: Introduce charset-based matching functions Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 12/13] ext4: Support charset name matching Gabriel Krisman Bertazi
2018-01-12  7:12 ` [PATCH RFC 13/13] ext4: Implement ext4 dcache hooks for custom charsets Gabriel Krisman Bertazi
2018-01-12 10:52   ` Weber, Olaf (HPC Data Management & Storage) [this message]
2018-01-12 16:56 ` [PATCH RFC 00/13] UTF-8 case insensitive lookups for EXT4 Jeremy Allison

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=DF4PR8401MB0812FF0D5F50D89C14015C0485170@DF4PR8401MB0812.NAMPRD84.PROD.OUTLOOK.COM \
    --to=olaf.weber@hpe.com \
    --cc=alvaro.soliverez@collabora.co.uk \
    --cc=bpm@sgi.com \
    --cc=david@fromorbit.com \
    --cc=kernel@lists.collabora.co.uk \
    --cc=krisman@collabora.co.uk \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=olaf@sgi.com \
    --cc=tytso@mit.edu \
    --subject='RE: [PATCH RFC 13/13] ext4: Implement ext4 dcache hooks for custom charsets' \
    /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

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).