Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp148203ybt; Tue, 7 Jul 2020 18:42:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzys2LWp9xB6MasFL1m8GxyMG16nO9r5V97D+RsoyXIoOIcBc5m3hZWmF6ZQjSVB56tgJwz X-Received: by 2002:a17:906:194b:: with SMTP id b11mr43673406eje.28.1594172537262; Tue, 07 Jul 2020 18:42:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594172537; cv=none; d=google.com; s=arc-20160816; b=0U4bQigNydiJk6uvWPwvj8BFvxRQdQH/CZc2Ocdjkt/hVkrE/j5A2KZ7GgQMbUHZRO 2gbv8F7kZrDGDScR8oHGRQP+BF6uqEDwFweOLsKRDhy/8R+i4mlasoAZxhKgRaPE2N3N YiMpzL193eevoWsMtDTHxoGgiqgQ9eCT3DzpvnbtFLsdsnIaaqtTNz5Q3tSy2nd78ztK cGufmP4KOVhcVseGzXri2ZCn+Zh2pcBy52/3H4MKyu4mwcmsGQIQj49+ZCezc/y9evjF GGcZeUT8UHMfX3eOscVpfKKGxn6+7a6uHonO/rdOEZ04MxJ7R+awK/+uSs9mnuT3faZZ SPbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=VjyjEH9kshElZBPMCE6toRsX+v4R/pL3SafFdqSs4i0=; b=RuiZf9AaHVgRGLblbo5viSQWnGt0f4qZZTPffRB5/14o/w3PwDjvGVfBut3WoImNTL 0zl/0WV7LWWWtA+0OfvTP+gTnVCAlxTkupKBdFjGrMzcllOAQCwUDdag0JQ5uUudQ5fI 1nLM+/dpZjGOTNsWPn8GC1wBiTX1qzx2ZJLUR4T3Ya1Z3f7PkmiLJ0OG7A9wp7WqRjsX 2ohJgMfqc/Fy9UrKlodshQ0QEUk8PSTR2yA/L0F/oYF27rS/wWCeSLJsOVxx2brm/GF+ cho/MSG5KZO2QouEAAJSpaDLRQqIf3kz4dXAv5WZqrjJ3BvBxj9AmadJrV6p2X7qFqQU R8ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oxcXuBLg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si15097055eju.736.2020.07.07.18.41.54; Tue, 07 Jul 2020 18:42:17 -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; dkim=pass header.i=@kernel.org header.s=default header.b=oxcXuBLg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728894AbgGHBlU (ORCPT + 99 others); Tue, 7 Jul 2020 21:41:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:50510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728417AbgGHBlU (ORCPT ); Tue, 7 Jul 2020 21:41:20 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F3A74206DF; Wed, 8 Jul 2020 01:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594172479; bh=KAvFbnLGnnoN00vC1m9a7iUoWjJr1jCD7u4eNPmMldM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oxcXuBLgev+EmuOUJZ9xxnkt0hBRav9qYoi7+9qx2aRXuk3wI+obdTPMA4wLc01Ub qRgbpbnRamihiDOUJM0sRoCQ9boGhBrJGnqhrXYv9YQKgmYSMLDIb02Ix9DqzOy+rD PGou2nZqy4vEsYIx2llEo4tZE5Fa8wNOCopEAnFk= Date: Tue, 7 Jul 2020 18:41:17 -0700 From: Eric Biggers To: Daniel Rosenberg Cc: Theodore Ts'o , linux-ext4@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-fscrypt@vger.kernel.org, Alexander Viro , Andreas Dilger , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , kernel-team@android.com Subject: Re: [PATCH v10 3/4] f2fs: Use generic casefolding support Message-ID: <20200708014117.GG839@sol.localdomain> References: <20200707113123.3429337-1-drosen@google.com> <20200707113123.3429337-4-drosen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200707113123.3429337-4-drosen@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 07, 2020 at 04:31:22AM -0700, Daniel Rosenberg wrote: > This switches f2fs over to the generic support provided in > the previous patch. > > Since casefolded dentries behave the same in ext4 and f2fs, we decrease > the maintenance burden by unifying them, and any optimizations will > immediately apply to both. > > Signed-off-by: Daniel Rosenberg > --- > fs/f2fs/dir.c | 83 +++++------------------------------------ > fs/f2fs/f2fs.h | 4 -- > fs/f2fs/super.c | 10 ++--- > fs/f2fs/sysfs.c | 10 +++-- > include/linux/f2fs_fs.h | 3 -- > 5 files changed, 20 insertions(+), 90 deletions(-) Looks good, you can add: Reviewed-by: Eric Biggers One nit below: > #ifdef CONFIG_UNICODE > -static int f2fs_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 *dir = READ_ONCE(parent->d_inode); > - const struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); > - struct qstr entry = QSTR_INIT(str, len); > - char strbuf[DNAME_INLINE_LEN]; > - int res; > - > - if (!dir || !IS_CASEFOLDED(dir)) > - goto fallback; > - > - /* > - * If the dentry name is stored in-line, then it may be concurrently > - * modified by a rename. If this happens, the VFS will eventually retry > - * the lookup, so it doesn't matter what ->d_compare() returns. > - * However, it's unsafe to call utf8_strncasecmp() with an unstable > - * string. Therefore, we have to copy the name into a temporary buffer. > - */ > - if (len <= DNAME_INLINE_LEN - 1) { > - memcpy(strbuf, str, len); > - strbuf[len] = 0; > - entry.name = strbuf; > - /* prevent compiler from optimizing out the temporary buffer */ > - barrier(); > - } > - > - res = utf8_strncasecmp(sbi->s_encoding, name, &entry); > - if (res >= 0) > - return res; > - > - if (f2fs_has_strict_mode(sbi)) > - return -EINVAL; > -fallback: > - if (len != name->len) > - return 1; > - return !!memcmp(str, name->name, len); > -} > - > -static int f2fs_d_hash(const struct dentry *dentry, struct qstr *str) > -{ > - struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); > - const struct unicode_map *um = sbi->s_encoding; > - const struct inode *inode = READ_ONCE(dentry->d_inode); > - unsigned char *norm; > - int len, ret = 0; > - > - if (!inode || !IS_CASEFOLDED(inode)) > - return 0; > - > - norm = f2fs_kmalloc(sbi, PATH_MAX, GFP_ATOMIC); > - if (!norm) > - return -ENOMEM; > - > - len = utf8_casefold(um, str, norm, PATH_MAX); > - if (len < 0) { > - if (f2fs_has_strict_mode(sbi)) > - ret = -EINVAL; > - goto out; > - } > - str->hash = full_name_hash(dentry, norm, len); > -out: > - kvfree(norm); > - return ret; > -} > > const struct dentry_operations f2fs_dentry_ops = { > - .d_hash = f2fs_d_hash, > - .d_compare = f2fs_d_compare, > + .d_hash = generic_ci_d_hash, > + .d_compare = generic_ci_d_compare, > }; > #endif This leaves an extra blank line just above f2fs_dentry_ops. - Eric