From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E49CC2BA83 for ; Sat, 8 Feb 2020 01:36:18 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CFD6F222D9 for ; Sat, 8 Feb 2020 01:36:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.sourceforge.net header.i=@lists.sourceforge.net header.b="WxV7fBmJ"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="R9LrRcS5"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="DNESx81X"; dkim=neutral (0-bit key) header.d=google.com header.i=@google.com header.b="wF1R/+nZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFD6F222D9 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=lists.sourceforge.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:To:References:Mime-Version:Message-Id: In-Reply-To:Date:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9h7T0mtqqwLc3jF4loInEHSODE5Rycw9953Qa6WnrdQ=; b=WxV7fBmJIP4exCLS/lKr0XkVN oKWOvlRfsKyVlGcYwq8GFr8I2k/o8k8efXsZv+ZIMPe0NUKBAoMy4Hi9cDBJm/TBUiwoAjoORkcfk q672qX+3Pyd5YNQx621cyyHqW3Q9pA/uRQ08cI31Ru8aS/c1bkzR7rffQw01PIDFhsSvo=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1j0F2f-0006Wi-BP; Sat, 08 Feb 2020 01:36:17 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from <3hRA-XgYKAJY3HEI4D6EE6B4.2EC@flex--drosen.bounces.google.com>) id 1j0F2d-0006WP-PT for linux-f2fs-devel@lists.sourceforge.net; Sat, 08 Feb 2020 01:36:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uDtcK8IvKRVIhF3NNKMXAHQKbhLHTBFI7hWh23GRRGk=; b=R9LrRcS5pPY0V08P56Xu/svWk DeJffkZ4SnbhM12Nhmj4pI3aV97WLoJpLzsfWshoeXfx0BDoLT8XVrK5aBlHwGg9I3j0vhW+bLgId wHvpg8YnXEayvwyx7XyMM6I1yTb19uC+jq93Yio98r+W7aux2EADJiDU9DNYU+jP57Hj4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=uDtcK8IvKRVIhF3NNKMXAHQKbhLHTBFI7hWh23GRRGk=; b=DNESx81XuNRz1hg8r00d3D9O0h ExoZNEosddgK9f88QQ+j4PKRhPKvEfyppINx8NJHrjOfzT4tq+Dr67yvFTtc5Q6GGZuu0jdI62fBk Z1p6j8OiQmHtI6PDyLl/SP80pQpwsNR5tqQ4rA9YVcLJjm8JKsW6b6fZKiUgBv3qwAVQ=; Received: from mail-pg1-f202.google.com ([209.85.215.202]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1j0F2Z-00DrQ4-TG for linux-f2fs-devel@lists.sourceforge.net; Sat, 08 Feb 2020 01:36:13 +0000 Received: by mail-pg1-f202.google.com with SMTP id a4so766590pgm.23 for ; Fri, 07 Feb 2020 17:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=uDtcK8IvKRVIhF3NNKMXAHQKbhLHTBFI7hWh23GRRGk=; b=wF1R/+nZ/ehOyPKpiugwZWtHob55+Fv9uOTD9x2oNsYAu/BSfvuT48JM0gujLXiWuP aKiZgzvdBhN/FBknmVthcfhq8wn9bBheIlryx6pSd568ew7a6G2pNDyU+Ej4zBC/GDZ8 8Aav0bp2I5vfZY4ODp5KFPugEVcMDw2faMbgVBOM8jnBDF+tIhnJvaNs8cAv94zgmAQI vji2whAXxwQPEDjXvJ8mu0VyS6RdeSS53AERbW3SIsLEgvWKT3E+P9KbhUoRHly9i8Hx U0CeIErCJFoQptfMXKsS+HPsBYd3+/c6GRVmCAheYNodL1fnQfW1Mw8w8OouJZqcmDJv +1Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=uDtcK8IvKRVIhF3NNKMXAHQKbhLHTBFI7hWh23GRRGk=; b=YkJWoniKZRBkaWKq68Lg4MpXSqMin8M4cfS4/79dOYvgGihWpvmLF93wq3BJikAErH wK7vUZhAyC6Zo86DaNPO3gG8TtJhGgg9LTvhVBsmBji7lhdRliAaFMAU6mhckrmA6OU7 tjCT1ELjhaEV21lnkrwU7gWdX61oU4ZXSTv/VCy/Mlg7fwhS/lqNrmGM84RvTh1+ExPd 5xFD3ciE/QXvZ/0iZ3oXC4P0gi/0S1HREiqvry4Ok4g1SvcQlWDUY6+npN5o9u3Iei35 k7wXtlt5aq28mmtNtAV29XihvecnXTb7fp0QUbvqPEOsZVjugMq8q6hG4Pf6BOakcW22 2IlA== X-Gm-Message-State: APjAAAUmuEzSdE8EJ158de75PvNF4+ehWLyfZnsXPhT0HWWoBG109+qZ AUr8hJjalWU5YIa8xeOpbCE+1RDGW4Q= X-Google-Smtp-Source: APXvYqzR3pBSZkCJBRB3eN0Y6FrWZ+6Xzpkh2qvATzwWPindBCqySbJq6EPrE07gW5BErtfnUniIa2W3+UY= X-Received: by 2002:a63:e4d:: with SMTP id 13mr2038532pgo.343.1581125765922; Fri, 07 Feb 2020 17:36:05 -0800 (PST) Date: Fri, 7 Feb 2020 17:35:48 -0800 In-Reply-To: <20200208013552.241832-1-drosen@google.com> Message-Id: <20200208013552.241832-5-drosen@google.com> Mime-Version: 1.0 References: <20200208013552.241832-1-drosen@google.com> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog To: "Theodore Ts'o" , linux-ext4@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, Eric Biggers , linux-fscrypt@vger.kernel.org, Alexander Viro , Richard Weinberger X-Headers-End: 1j0F2Z-00DrQ4-TG Subject: [f2fs-dev] [PATCH v7 4/8] ext4: Use generic casefolding support X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Daniel Rosenberg via Linux-f2fs-devel Reply-To: Daniel Rosenberg Cc: Daniel Rosenberg , linux-doc@vger.kernel.org, kernel-team@android.com, Jonathan Corbet , linux-kernel@vger.kernel.org, Andreas Dilger , linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org, Gabriel Krisman Bertazi Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Archived-At: List-Archive: This switches ext4 over to the generic support provided in commit 65832afbeaaf ("fs: Add standard casefolding support") Signed-off-by: Daniel Rosenberg --- fs/ext4/dir.c | 48 ++---------------------------------------------- fs/ext4/ext4.h | 12 ------------ fs/ext4/hash.c | 2 +- fs/ext4/namei.c | 20 ++++++++------------ fs/ext4/super.c | 12 ++++++------ 5 files changed, 17 insertions(+), 77 deletions(-) diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index 1f340743c9a89..128198ed1a96f 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c @@ -667,52 +667,8 @@ const struct file_operations ext4_dir_operations = { }; #ifdef CONFIG_UNICODE -static int ext4_d_compare(const struct dentry *dentry, unsigned int len, - const char *str, const struct qstr *name) -{ - struct qstr qstr = {.name = str, .len = len }; - const struct dentry *parent = READ_ONCE(dentry->d_parent); - const struct inode *inode = READ_ONCE(parent->d_inode); - - if (!inode || !IS_CASEFOLDED(inode) || - !EXT4_SB(inode->i_sb)->s_encoding) { - if (len != name->len) - return -1; - return memcmp(str, name->name, len); - } - - return ext4_ci_compare(inode, name, &qstr, false); -} - -static int ext4_d_hash(const struct dentry *dentry, struct qstr *str) -{ - const struct ext4_sb_info *sbi = EXT4_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) || !um) - return 0; - - norm = kmalloc(PATH_MAX, GFP_ATOMIC); - if (!norm) - return -ENOMEM; - - len = utf8_casefold(um, str, norm, PATH_MAX); - if (len < 0) { - if (ext4_has_strict_mode(sbi)) - ret = -EINVAL; - goto out; - } - str->hash = full_name_hash(dentry, norm, len); -out: - kfree(norm); - return ret; -} - const struct dentry_operations ext4_dentry_ops = { - .d_hash = ext4_d_hash, - .d_compare = ext4_d_compare, + .d_hash = generic_ci_d_hash, + .d_compare = generic_ci_d_compare, }; #endif diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 9a2ee2428ecc0..237885dd1cf96 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1372,14 +1372,6 @@ struct ext4_super_block { #define EXT4_ENC_UTF8_12_1 1 -/* - * Flags for ext4_sb_info.s_encoding_flags. - */ -#define EXT4_ENC_STRICT_MODE_FL (1 << 0) - -#define ext4_has_strict_mode(sbi) \ - (sbi->s_encoding_flags & EXT4_ENC_STRICT_MODE_FL) - /* * fourth extended-fs super-block data in memory */ @@ -1429,10 +1421,6 @@ struct ext4_sb_info { struct kobject s_kobj; struct completion s_kobj_unregister; struct super_block *s_sb; -#ifdef CONFIG_UNICODE - struct unicode_map *s_encoding; - __u16 s_encoding_flags; -#endif /* Journaling */ struct journal_s *s_journal; diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c index 3e133793a5a34..143b0073b3f46 100644 --- a/fs/ext4/hash.c +++ b/fs/ext4/hash.c @@ -275,7 +275,7 @@ int ext4fs_dirhash(const struct inode *dir, const char *name, int len, struct dx_hash_info *hinfo) { #ifdef CONFIG_UNICODE - const struct unicode_map *um = EXT4_SB(dir->i_sb)->s_encoding; + const struct unicode_map *um = dir->i_sb->s_encoding; int r, dlen; unsigned char *buff; struct qstr qstr = {.name = name, .len = len }; diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 129d2ebae00d0..53ce3c331528e 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -1286,8 +1286,8 @@ static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block) int ext4_ci_compare(const struct inode *parent, const struct qstr *name, const struct qstr *entry, bool quick) { - const struct ext4_sb_info *sbi = EXT4_SB(parent->i_sb); - const struct unicode_map *um = sbi->s_encoding; + const struct super_block *sb = parent->i_sb; + const struct unicode_map *um = sb->s_encoding; int ret; if (quick) @@ -1299,7 +1299,7 @@ int ext4_ci_compare(const struct inode *parent, const struct qstr *name, /* Handle invalid character sequence as either an error * or as an opaque byte sequence. */ - if (ext4_has_strict_mode(sbi)) + if (sb_has_enc_strict_mode(sb)) return -EINVAL; if (name->len != entry->len) @@ -1316,7 +1316,7 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, { int len; - if (!IS_CASEFOLDED(dir) || !EXT4_SB(dir->i_sb)->s_encoding) { + if (!needs_casefold(dir)) { cf_name->name = NULL; return; } @@ -1325,7 +1325,7 @@ void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, if (!cf_name->name) return; - len = utf8_casefold(EXT4_SB(dir->i_sb)->s_encoding, + len = utf8_casefold(dir->i_sb->s_encoding, iname, cf_name->name, EXT4_NAME_LEN); if (len <= 0) { @@ -1362,7 +1362,7 @@ static inline bool ext4_match(const struct inode *parent, #endif #ifdef CONFIG_UNICODE - if (EXT4_SB(parent->i_sb)->s_encoding && IS_CASEFOLDED(parent)) { + if (needs_casefold(parent)) { if (fname->cf_name.name) { struct qstr cf = {.name = fname->cf_name.name, .len = fname->cf_name.len}; @@ -2170,9 +2170,6 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, struct buffer_head *bh = NULL; struct ext4_dir_entry_2 *de; struct super_block *sb; -#ifdef CONFIG_UNICODE - struct ext4_sb_info *sbi; -#endif struct ext4_filename fname; int retval; int dx_fallback=0; @@ -2189,9 +2186,8 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, return -EINVAL; #ifdef CONFIG_UNICODE - sbi = EXT4_SB(sb); - if (ext4_has_strict_mode(sbi) && IS_CASEFOLDED(dir) && - sbi->s_encoding && utf8_validate(sbi->s_encoding, &dentry->d_name)) + if (sb_has_enc_strict_mode(sb) && IS_CASEFOLDED(dir) && + sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name)) return -EINVAL; #endif diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 8434217549b30..9717c802d889d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1102,7 +1102,7 @@ static void ext4_put_super(struct super_block *sb) kfree(sbi->s_blockgroup_lock); fs_put_dax(sbi->s_daxdev); #ifdef CONFIG_UNICODE - utf8_unload(sbi->s_encoding); + utf8_unload(sb->s_encoding); #endif kfree(sbi); } @@ -3896,7 +3896,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) goto failed_mount; #ifdef CONFIG_UNICODE - if (ext4_has_feature_casefold(sb) && !sbi->s_encoding) { + if (ext4_has_feature_casefold(sb) && !sb->s_encoding) { const struct ext4_sb_encodings *encoding_info; struct unicode_map *encoding; __u16 encoding_flags; @@ -3927,8 +3927,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) "%s-%s with flags 0x%hx", encoding_info->name, encoding_info->version?:"\b", encoding_flags); - sbi->s_encoding = encoding; - sbi->s_encoding_flags = encoding_flags; + sb->s_encoding = encoding; + sb->s_encoding_flags = encoding_flags; } #endif @@ -4543,7 +4543,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) } #ifdef CONFIG_UNICODE - if (sbi->s_encoding) + if (sb->s_encoding) sb->s_d_op = &ext4_dentry_ops; #endif @@ -4729,7 +4729,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) crypto_free_shash(sbi->s_chksum_driver); #ifdef CONFIG_UNICODE - utf8_unload(sbi->s_encoding); + utf8_unload(sb->s_encoding); #endif #ifdef CONFIG_QUOTA -- 2.25.0.341.g760bfbb309-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel