Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4546994pxf; Tue, 23 Mar 2021 13:20:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN6mW7RxrKTBLKopbpzjJn2WYcIrcODPRsoQ8TeFFHhzThRF5iWXY1v7goWR2f6pbDNGdW X-Received: by 2002:a17:906:b2cd:: with SMTP id cf13mr6611790ejb.181.1616530854561; Tue, 23 Mar 2021 13:20:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616530854; cv=none; d=google.com; s=arc-20160816; b=MI0MA+C2LVTZgb3hwRaDkFkl3M/RMWY4XDcNj3y1DwCkDcpiF0D6atFpUNMmeiuo+k JlQcDFtqwCNS+xXNpsEsfmqaq9WWEsP7m/vKR9SiT5qmtMb2yrgfptKqhEReA6XYO+pD 4uwMvXKK1BJWwUVrKIv+WFWbuATDT5QFBxIc/Zvhf5QHurohqfaDpWh1hgzJlE6LjPh+ 6/uLftCqLn02Yz2A9PbyMVtVbF86Rb3TZgw06S/mPCopjknSD55KUxL7qnqDipiA/3/x KBwikWcS8PCyShuTynv4TwHOCL+G/OSDlWLPtiEhfZ3zoRAQw3leQC4GGmBUtfzUI8rn 3EUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:from; bh=E4Mh3ljo4o+kOnp6mkK8UZsS2gJJ0PJREkuHBLw423E=; b=kyESVnUKl0iMnlpeIEEQKgm4OjP0OR+hMvkVd4LAvVjON2BksV1kmr/QdSmFxUbEdy 9CCqnT7oWtOxCT9LK4fXtkVYJP6gg2uUCY1jynwoNTONnAdL2SFtDCkBZWCkI5h2Px8L TEh+3pq6HL5qKz5sLDPJSAoljkoJ0UvcHmWY/rNtW/0FXRRwJ7H7cy/XGNw4yRJ7cmhr siP0QDMQ/kgvdW8+b1hlQ8RDpvgVjwQ0f+w6DBZeA//5aSLpp/K2ELPVkY+Ol7l3DGRu zLSWcGwxn6q3eSpE0rB07tOh8QcesYgEvWD0hbDYht6/yr4a/DgSK99GjjIhHW4Voi1F p/Rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j16si49888edj.401.2021.03.23.13.20.30; Tue, 23 Mar 2021 13:20:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232783AbhCWUTQ convert rfc822-to-8bit (ORCPT + 99 others); Tue, 23 Mar 2021 16:19:16 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:54200 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbhCWUSr (ORCPT ); Tue, 23 Mar 2021 16:18:47 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 988EC1F40FE7 From: Gabriel Krisman Bertazi To: =?utf-8?Q?Andr=C3=A9?= Almeida Cc: Hugh Dickins , Andrew Morton , Alexander Viro , smcv@collabora.com, kernel@collabora.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Rosenberg Subject: Re: [RFC PATCH 2/4] mm: shmem: Support case-insensitive file name lookups Organization: Collabora References: <20210323195941.69720-1-andrealmeid@collabora.com> <20210323195941.69720-3-andrealmeid@collabora.com> Date: Tue, 23 Mar 2021 16:18:43 -0400 In-Reply-To: <20210323195941.69720-3-andrealmeid@collabora.com> (=?utf-8?Q?=22Andr=C3=A9?= Almeida"'s message of "Tue, 23 Mar 2021 16:59:39 -0300") Message-ID: <877dlxd3oc.fsf@collabora.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org André Almeida writes: > This patch implements the support for case-insensitive file name lookups > in tmpfs, based on the encoding passed in the mount options. Thanks for doing this. > > +#ifdef CONFIG_UNICODE > +static const struct dentry_operations casefold_dentry_ops = { > + .d_hash = generic_ci_d_hash, > + .d_compare = generic_ci_d_compare, > +}; > +#endif Why not reuse struct generic_ci_dentry_ops ? > + > /* > * shmem_file_setup pre-accounts the whole fixed size of a VM object, > * for shared memory and for shared anonymous (/dev/zero) mappings > @@ -2859,8 +2869,18 @@ shmem_mknod(struct user_namespace *mnt_userns, struct inode *dir, > struct inode *inode; > int error = -ENOSPC; > > +#ifdef CONFIG_UNICODE > + struct super_block *sb = dir->i_sb; > + > + if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) && > + sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name)) > + return -EINVAL; > +#endif > + > inode = shmem_get_inode(dir->i_sb, dir, mode, dev, VM_NORESERVE); > if (inode) { > + inode->i_flags |= dir->i_flags; > + > error = simple_acl_create(dir, inode); > if (error) > goto out_iput; > @@ -2870,6 +2890,9 @@ shmem_mknod(struct user_namespace *mnt_userns, struct inode *dir, > if (error && error != -EOPNOTSUPP) > goto out_iput; > > + if (IS_CASEFOLDED(dir)) > + d_add(dentry, NULL); > + > error = 0; > dir->i_size += BOGO_DIRENT_SIZE; > dir->i_ctime = dir->i_mtime = current_time(dir); > @@ -2925,6 +2948,19 @@ static int shmem_create(struct user_namespace *mnt_userns, struct inode *dir, > return shmem_mknod(&init_user_ns, dir, dentry, mode | S_IFREG, 0); > } > > +static struct dentry *shmem_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) > +{ > + if (dentry->d_name.len > NAME_MAX) > + return ERR_PTR(-ENAMETOOLONG); > + > + if (IS_CASEFOLDED(dir)) > + return NULL; I think this deserves a comment explaining why it is necessary. > + > + d_add(dentry, NULL); > + > + return NULL; > +} > + > /* > * Link a file.. > */ > @@ -2946,6 +2982,9 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, struct dentr > goto out; > } > > + if (IS_CASEFOLDED(dir)) > + d_add(dentry, NULL); > + > dir->i_size += BOGO_DIRENT_SIZE; > inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode); > inc_nlink(inode); > @@ -2967,6 +3006,10 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry) > inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode); > drop_nlink(inode); > dput(dentry); /* Undo the count from "create" - this does all the work */ > + > + if (IS_CASEFOLDED(dir)) > + d_invalidate(dentry); > + > return 0; > } > > @@ -3128,6 +3171,8 @@ static int shmem_symlink(struct user_namespace *mnt_userns, struct inode *dir, > } > dir->i_size += BOGO_DIRENT_SIZE; > dir->i_ctime = dir->i_mtime = current_time(dir); > + if (IS_CASEFOLDED(dir)) > + d_add(dentry, NULL); > d_instantiate(dentry, inode); > dget(dentry); > return 0; > @@ -3364,6 +3409,8 @@ enum shmem_param { > Opt_uid, > Opt_inode32, > Opt_inode64, > + Opt_casefold, > + Opt_cf_strict, > }; > > static const struct constant_table shmem_param_enums_huge[] = { > @@ -3385,6 +3432,8 @@ const struct fs_parameter_spec shmem_fs_parameters[] = { > fsparam_u32 ("uid", Opt_uid), > fsparam_flag ("inode32", Opt_inode32), > fsparam_flag ("inode64", Opt_inode64), > + fsparam_string("casefold", Opt_casefold), > + fsparam_flag ("cf_strict", Opt_cf_strict), > {} > }; > > @@ -3392,9 +3441,11 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) > { > struct shmem_options *ctx = fc->fs_private; > struct fs_parse_result result; > + struct unicode_map *encoding; > unsigned long long size; > + char version[10]; > char *rest; > - int opt; > + int opt, ret; > > opt = fs_parse(fc, shmem_fs_parameters, param, &result); > if (opt < 0) > @@ -3468,6 +3519,23 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) > ctx->full_inums = true; > ctx->seen |= SHMEM_SEEN_INUMS; > break; > + case Opt_casefold: > + if (strncmp(param->string, "utf8-", 5)) > + return invalfc(fc, "Only utf8 encondings are supported"); > + ret = strscpy(version, param->string + 5, sizeof(version)); Ugh. Now we are doing two strscpy for the parse api (in unicode_load). Can change the unicode_load api to reuse it? thanks, -- Gabriel Krisman Bertazi