static struct f2fs_dir_entry *find_in_block(struct inode *dir,
                                struct page *dentry_page,
                                const struct f2fs_filename *fname,
-                               int *max_slots)
+                               int *max_slots,
+                               bool use_hash)
 {
        struct f2fs_dentry_block *dentry_blk;
        struct f2fs_dentry_ptr d;
        dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page);
 
        make_dentry_ptr_block(dir, &d, dentry_blk);
-       return f2fs_find_target_dentry(&d, fname, max_slots);
+       return f2fs_find_target_dentry(&d, fname, max_slots, use_hash);
 }
 
 static inline int f2fs_match_name(const struct inode *dir,
 }
 
 struct f2fs_dir_entry *f2fs_find_target_dentry(const struct f2fs_dentry_ptr *d,
-                       const struct f2fs_filename *fname, int *max_slots)
+                       const struct f2fs_filename *fname, int *max_slots,
+                       bool use_hash)
 {
        struct f2fs_dir_entry *de;
        unsigned long bit_pos = 0;
                        continue;
                }
 
-               if (de->hash_code == fname->hash) {
+               if (!use_hash || de->hash_code == fname->hash) {
                        res = f2fs_match_name(d->inode, fname,
                                              d->filename[bit_pos],
                                              le16_to_cpu(de->name_len));
 static struct f2fs_dir_entry *find_in_level(struct inode *dir,
                                        unsigned int level,
                                        const struct f2fs_filename *fname,
-                                       struct page **res_page)
+                                       struct page **res_page,
+                                       bool use_hash)
 {
        int s = GET_DENTRY_SLOTS(fname->disk_name.len);
        unsigned int nbucket, nblock;
-       unsigned int bidx, end_block;
+       unsigned int bidx, end_block, bucket_no;
        struct page *dentry_page;
        struct f2fs_dir_entry *de = NULL;
        pgoff_t next_pgofs;
        nbucket = dir_buckets(level, F2FS_I(dir)->i_dir_level);
        nblock = bucket_blocks(level);
 
+       bucket_no = use_hash ? le32_to_cpu(fname->hash) % nbucket : 0;
+
+start_find_bucket:
        bidx = dir_block_index(level, F2FS_I(dir)->i_dir_level,
-                              le32_to_cpu(fname->hash) % nbucket);
+                              bucket_no);
        end_block = bidx + nblock;
 
        while (bidx < end_block) {
                        }
                }
 
-               de = find_in_block(dir, dentry_page, fname, &max_slots);
+               de = find_in_block(dir, dentry_page, fname, &max_slots, use_hash);
                if (IS_ERR(de)) {
                        *res_page = ERR_CAST(de);
                        de = NULL;
                bidx++;
        }
 
-       if (!de && room && F2FS_I(dir)->chash != fname->hash) {
-               F2FS_I(dir)->chash = fname->hash;
-               F2FS_I(dir)->clevel = level;
-       }
+       if (de)
+               return de;
 
-       return de;
+       if (likely(use_hash)) {
+               if (room && F2FS_I(dir)->chash != fname->hash) {
+                       F2FS_I(dir)->chash = fname->hash;
+                       F2FS_I(dir)->clevel = level;
+               }
+       } else if (++bucket_no < nbucket) {
+               goto start_find_bucket;
+       }
+       return NULL;
 }
 
 struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir,
        struct f2fs_dir_entry *de = NULL;
        unsigned int max_depth;
        unsigned int level;
+       bool use_hash = true;
 
        *res_page = NULL;
 
+#if IS_ENABLED(CONFIG_UNICODE)
+start_find_entry:
+#endif
        if (f2fs_has_inline_dentry(dir)) {
-               de = f2fs_find_in_inline_dir(dir, fname, res_page);
+               de = f2fs_find_in_inline_dir(dir, fname, res_page, use_hash);
                goto out;
        }
 
        }
 
        for (level = 0; level < max_depth; level++) {
-               de = find_in_level(dir, level, fname, res_page);
+               de = find_in_level(dir, level, fname, res_page, use_hash);
                if (de || IS_ERR(*res_page))
                        break;
        }
+
 out:
+#if IS_ENABLED(CONFIG_UNICODE)
+       if (IS_CASEFOLDED(dir) && !de && use_hash) {
+               use_hash = false;
+               goto start_find_entry;
+       }
+#endif
        /* This is to increase the speed of f2fs_create */
        if (!de)
                F2FS_I(dir)->task = current;
 
                        struct f2fs_filename *fname);
 void f2fs_free_filename(struct f2fs_filename *fname);
 struct f2fs_dir_entry *f2fs_find_target_dentry(const struct f2fs_dentry_ptr *d,
-                       const struct f2fs_filename *fname, int *max_slots);
+                       const struct f2fs_filename *fname, int *max_slots,
+                       bool use_hash);
 int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
                        unsigned int start_pos, struct fscrypt_str *fstr);
 void f2fs_do_make_empty_dir(struct inode *inode, struct inode *parent,
 int f2fs_recover_inline_data(struct inode *inode, struct page *npage);
 struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir,
                                        const struct f2fs_filename *fname,
-                                       struct page **res_page);
+                                       struct page **res_page,
+                                       bool use_hash);
 int f2fs_make_empty_inline_dir(struct inode *inode, struct inode *parent,
                        struct page *ipage);
 int f2fs_add_inline_entry(struct inode *dir, const struct f2fs_filename *fname,