/* * Find an entry in the specified directory with the wanted name. * It returns the page where the entry was found (as a parameter - res_page), * and the entry itself. Page is returned mapped and unlocked. * Entry is guaranteed to be valid. */ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, struct qstr *child, struct page **res_page) { unsigned long npages = dir_blocks(dir); struct f2fs_dir_entry *de = NULL; f2fs_hash_t name_hash; unsigned int max_depth; unsigned int level; if (npages == 0) return NULL; *res_page = NULL; name_hash = f2fs_dentry_hash(child); max_depth = F2FS_I(dir)->i_current_depth; for (level = 0; level < max_depth; level++) { de = find_in_level(dir, level, child, name_hash, res_page); if (de) break; } if (!de && F2FS_I(dir)->chash != name_hash) { F2FS_I(dir)->chash = name_hash; F2FS_I(dir)->clevel = level - 1; } return de; }
static int f2fs_find_entry(struct f2fs_sb_info *sbi, struct f2fs_node *dir, struct dentry *de) { unsigned int max_depth; unsigned int level; max_depth = le32_to_cpu(dir->i.i_current_depth); for (level = 0; level < max_depth; level ++) { if (find_in_level(sbi, dir, level, de)) return 1; } return 0; }