Lines Matching full:dir
3 * fs/f2fs/dir.c
46 /* If @dir is casefolded, initialize @fname->cf_name from @fname->usr_fname. */
47 int f2fs_init_casefolded_name(const struct inode *dir, in f2fs_init_casefolded_name() argument
50 struct super_block *sb = dir->i_sb; in f2fs_init_casefolded_name()
54 if (IS_CASEFOLDED(dir) && in f2fs_init_casefolded_name()
88 static int __f2fs_setup_filename(const struct inode *dir, in __f2fs_setup_filename() argument
105 err = f2fs_init_casefolded_name(dir, fname); in __f2fs_setup_filename()
110 f2fs_hash_filename(dir, fname); in __f2fs_setup_filename()
116 * Prepare to search for @iname in @dir. This is similar to
121 int f2fs_setup_filename(struct inode *dir, const struct qstr *iname, in f2fs_setup_filename() argument
127 err = fscrypt_setup_filename(dir, iname, lookup, &crypt_name); in f2fs_setup_filename()
131 return __f2fs_setup_filename(dir, &crypt_name, fname); in f2fs_setup_filename()
135 * Prepare to look up @dentry in @dir. This is similar to
140 int f2fs_prepare_lookup(struct inode *dir, struct dentry *dentry, in f2fs_prepare_lookup() argument
146 err = fscrypt_prepare_lookup(dir, dentry, &crypt_name); in f2fs_prepare_lookup()
150 return __f2fs_setup_filename(dir, &crypt_name, fname); in f2fs_prepare_lookup()
175 static struct f2fs_dir_entry *find_in_block(struct inode *dir, in find_in_block() argument
185 make_dentry_ptr_block(dir, &d, dentry_blk); in find_in_block()
189 static inline int f2fs_match_name(const struct inode *dir, in f2fs_match_name() argument
197 return generic_ci_match(dir, fname->usr_fname, in f2fs_match_name()
258 static struct f2fs_dir_entry *find_in_level(struct inode *dir, in find_in_level() argument
272 nbucket = dir_buckets(level, F2FS_I(dir)->i_dir_level); in find_in_level()
275 bidx = dir_block_index(level, F2FS_I(dir)->i_dir_level, in find_in_level()
281 dentry_page = f2fs_find_data_page(dir, bidx, &next_pgofs); in find_in_level()
293 de = find_in_block(dir, dentry_page, fname, &max_slots); in find_in_level()
310 if (!de && room && F2FS_I(dir)->chash != fname->hash) { in find_in_level()
311 F2FS_I(dir)->chash = fname->hash; in find_in_level()
312 F2FS_I(dir)->clevel = level; in find_in_level()
318 struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir, in __f2fs_find_entry() argument
322 unsigned long npages = dir_blocks(dir); in __f2fs_find_entry()
329 if (f2fs_has_inline_dentry(dir)) { in __f2fs_find_entry()
330 de = f2fs_find_in_inline_dir(dir, fname, res_page); in __f2fs_find_entry()
337 max_depth = F2FS_I(dir)->i_current_depth; in __f2fs_find_entry()
339 f2fs_warn(F2FS_I_SB(dir), "Corrupted max_depth of %lu: %u", in __f2fs_find_entry()
340 dir->i_ino, max_depth); in __f2fs_find_entry()
342 f2fs_i_depth_write(dir, max_depth); in __f2fs_find_entry()
346 de = find_in_level(dir, level, fname, res_page); in __f2fs_find_entry()
353 F2FS_I(dir)->task = current; in __f2fs_find_entry()
363 struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir, in f2fs_find_entry() argument
370 err = f2fs_setup_filename(dir, child, 1, &fname); in f2fs_find_entry()
379 de = __f2fs_find_entry(dir, &fname, res_page); in f2fs_find_entry()
385 struct f2fs_dir_entry *f2fs_parent_dir(struct inode *dir, struct page **p) in f2fs_parent_dir() argument
387 return f2fs_find_entry(dir, &dotdot_name, p); in f2fs_parent_dir()
390 ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr, in f2fs_inode_by_name() argument
396 de = f2fs_find_entry(dir, qstr, page); in f2fs_inode_by_name()
405 void f2fs_set_link(struct inode *dir, struct f2fs_dir_entry *de, in f2fs_set_link() argument
408 enum page_type type = f2fs_has_inline_dentry(dir) ? NODE : DATA; in f2fs_set_link()
416 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); in f2fs_set_link()
417 f2fs_mark_inode_dirty_sync(dir, false); in f2fs_set_link()
421 static void init_dent_inode(struct inode *dir, struct inode *inode, in init_dent_inode() argument
436 if (IS_ENCRYPTED(dir)) { in init_dent_inode()
445 if (IS_CASEFOLDED(dir)) { in init_dent_inode()
494 struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir, in f2fs_init_inode_metadata() argument
508 err = make_empty_dir(inode, dir, page); in f2fs_init_inode_metadata()
516 err = f2fs_init_acl(inode, dir, page, dpage); in f2fs_init_inode_metadata()
520 err = f2fs_init_security(inode, dir, in f2fs_init_inode_metadata()
531 page = f2fs_get_node_page(F2FS_I_SB(dir), inode->i_ino); in f2fs_init_inode_metadata()
536 init_dent_inode(dir, inode, fname, page); in f2fs_init_inode_metadata()
550 f2fs_remove_orphan_inode(F2FS_I_SB(dir), inode->i_ino); in f2fs_init_inode_metadata()
562 void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode, in f2fs_update_parent_metadata() argument
567 f2fs_i_links_write(dir, true); in f2fs_update_parent_metadata()
570 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); in f2fs_update_parent_metadata()
571 f2fs_mark_inode_dirty_sync(dir, false); in f2fs_update_parent_metadata()
573 if (F2FS_I(dir)->i_current_depth != current_depth) in f2fs_update_parent_metadata()
574 f2fs_i_depth_write(dir, current_depth); in f2fs_update_parent_metadata()
600 bool f2fs_has_enough_room(struct inode *dir, struct page *ipage, in f2fs_has_enough_room() argument
607 make_dentry_ptr_inline(dir, &d, inline_data_addr(dir, ipage)); in f2fs_has_enough_room()
636 int f2fs_add_regular_entry(struct inode *dir, const struct f2fs_filename *fname, in f2fs_add_regular_entry() argument
653 current_depth = F2FS_I(dir)->i_current_depth; in f2fs_add_regular_entry()
654 if (F2FS_I(dir)->chash == fname->hash) { in f2fs_add_regular_entry()
655 level = F2FS_I(dir)->clevel; in f2fs_add_regular_entry()
656 F2FS_I(dir)->chash = 0; in f2fs_add_regular_entry()
660 if (time_to_inject(F2FS_I_SB(dir), FAULT_DIR_DEPTH)) in f2fs_add_regular_entry()
670 nbucket = dir_buckets(level, F2FS_I(dir)->i_dir_level); in f2fs_add_regular_entry()
673 bidx = dir_block_index(level, F2FS_I(dir)->i_dir_level, in f2fs_add_regular_entry()
677 dentry_page = f2fs_get_new_data_page(dir, NULL, block, true); in f2fs_add_regular_entry()
698 page = f2fs_init_inode_metadata(inode, dir, fname, NULL); in f2fs_add_regular_entry()
712 f2fs_i_pino_write(inode, dir->i_ino); in f2fs_add_regular_entry()
721 f2fs_update_parent_metadata(dir, inode, current_depth); in f2fs_add_regular_entry()
731 int f2fs_add_dentry(struct inode *dir, const struct f2fs_filename *fname, in f2fs_add_dentry() argument
736 if (f2fs_has_inline_dentry(dir)) { in f2fs_add_dentry()
741 f2fs_down_read(&F2FS_I(dir)->i_xattr_sem); in f2fs_add_dentry()
742 err = f2fs_add_inline_entry(dir, fname, inode, ino, mode); in f2fs_add_dentry()
743 f2fs_up_read(&F2FS_I(dir)->i_xattr_sem); in f2fs_add_dentry()
746 err = f2fs_add_regular_entry(dir, fname, inode, ino, mode); in f2fs_add_dentry()
748 f2fs_update_time(F2FS_I_SB(dir), REQ_TIME); in f2fs_add_dentry()
756 int f2fs_do_add_link(struct inode *dir, const struct qstr *name, in f2fs_do_add_link() argument
764 err = f2fs_setup_filename(dir, name, 0, &fname); in f2fs_do_add_link()
775 if (current != F2FS_I(dir)->task) { in f2fs_do_add_link()
776 de = __f2fs_find_entry(dir, &fname, &page); in f2fs_do_add_link()
777 F2FS_I(dir)->task = NULL; in f2fs_do_add_link()
785 err = f2fs_add_dentry(dir, &fname, inode, ino, mode); in f2fs_do_add_link()
791 int f2fs_do_tmpfile(struct inode *inode, struct inode *dir, in f2fs_do_tmpfile() argument
798 page = f2fs_init_inode_metadata(inode, dir, fname, NULL); in f2fs_do_tmpfile()
812 void f2fs_drop_nlink(struct inode *dir, struct inode *inode) in f2fs_drop_nlink() argument
814 struct f2fs_sb_info *sbi = F2FS_I_SB(dir); in f2fs_drop_nlink()
819 f2fs_i_links_write(dir, false); in f2fs_drop_nlink()
840 struct inode *dir, struct inode *inode) in f2fs_delete_entry() argument
848 f2fs_update_time(F2FS_I_SB(dir), REQ_TIME); in f2fs_delete_entry()
850 if (F2FS_OPTION(F2FS_I_SB(dir)).fsync_mode == FSYNC_MODE_STRICT) in f2fs_delete_entry()
851 f2fs_add_ino_entry(F2FS_I_SB(dir), dir->i_ino, TRANS_DIR_INO); in f2fs_delete_entry()
853 if (f2fs_has_inline_dentry(dir)) in f2fs_delete_entry()
854 return f2fs_delete_inline_entry(dentry, page, dir, inode); in f2fs_delete_entry()
871 !f2fs_truncate_hole(dir, index, index + 1)) { in f2fs_delete_entry()
877 inode_dec_dirty_pages(dir); in f2fs_delete_entry()
878 f2fs_remove_dirty_inode(dir); in f2fs_delete_entry()
882 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); in f2fs_delete_entry()
883 f2fs_mark_inode_dirty_sync(dir, false); in f2fs_delete_entry()
886 f2fs_drop_nlink(dir, inode); in f2fs_delete_entry()
889 bool f2fs_empty_dir(struct inode *dir) in f2fs_empty_dir() argument
895 unsigned long nblock = dir_blocks(dir); in f2fs_empty_dir()
897 if (f2fs_has_inline_dentry(dir)) in f2fs_empty_dir()
898 return f2fs_empty_inline_dir(dir); in f2fs_empty_dir()
903 dentry_page = f2fs_find_data_page(dir, bidx, &next_pgofs); in f2fs_empty_dir()
1054 /* readahead for multi pages of dir */ in f2fs_readdir()