Lines Matching full:dir
302 static unsigned dx_root_limit(struct inode *dir, unsigned infosize);
303 static unsigned dx_node_limit(struct inode *dir);
305 struct inode *dir,
309 static int dx_make_map(struct inode *dir, struct buffer_head *bh,
313 static struct ext4_dir_entry_2 *dx_move_dirents(struct inode *dir, char *from,
316 static struct ext4_dir_entry_2 *dx_pack_dirents(struct inode *dir, char *base,
320 static int ext4_htree_next_block(struct inode *dir, __u32 hash,
324 static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
328 struct inode *dir, struct inode *inode);
502 EXT4_ERROR_INODE(inode, "dir seems corrupt? Run e2fsck -D."); in ext4_dx_csum_verify()
531 EXT4_ERROR_INODE(inode, "dir seems corrupt? Run e2fsck -D."); in ext4_dx_csum_set()
609 static inline unsigned dx_root_limit(struct inode *dir, unsigned infosize) in dx_root_limit() argument
611 unsigned int entry_space = dir->i_sb->s_blocksize - in dx_root_limit()
615 if (ext4_has_metadata_csum(dir->i_sb)) in dx_root_limit()
620 static inline unsigned dx_node_limit(struct inode *dir) in dx_node_limit() argument
622 unsigned int entry_space = dir->i_sb->s_blocksize - in dx_node_limit()
623 ext4_dir_rec_len(0, dir); in dx_node_limit()
625 if (ext4_has_metadata_csum(dir->i_sb)) in dx_node_limit()
653 static struct stats dx_show_leaf(struct inode *dir, in dx_show_leaf() argument
678 if (!IS_ENCRYPTED(dir)) { in dx_show_leaf()
680 (void) ext4fs_dirhash(dir, de->name, in dx_show_leaf()
698 res = fscrypt_fname_disk_to_usr(dir, in dx_show_leaf()
712 if (IS_CASEFOLDED(dir)) in dx_show_leaf()
715 (void) ext4fs_dirhash(dir, in dx_show_leaf()
727 (void) ext4fs_dirhash(dir, de->name, in dx_show_leaf()
733 space += ext4_dir_rec_len(de->name_len, dir); in dx_show_leaf()
742 struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir, in dx_show_entries() argument
745 unsigned blocksize = dir->i_sb->s_blocksize; in dx_show_entries()
757 bh = ext4_bread(NULL,dir, block, 0); in dx_show_entries()
761 dx_show_entries(hinfo, dir, ((struct dx_node *) bh->b_data)->entries, levels - 1): in dx_show_entries()
762 dx_show_leaf(dir, hinfo, (struct ext4_dir_entry_2 *) in dx_show_entries()
810 dx_probe(struct ext4_filename *fname, struct inode *dir, in dx_probe() argument
823 frame->bh = ext4_read_dirblock(dir, 0, INDEX); in dx_probe()
832 ext4_warning_inode(dir, "Unrecognised inode hash code %u", in dx_probe()
836 if (ext4_hash_in_dirent(dir)) { in dx_probe()
838 ext4_warning_inode(dir, in dx_probe()
844 ext4_warning_inode(dir, in dx_probe()
853 hinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; in dx_probe()
854 hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed; in dx_probe()
857 !(IS_ENCRYPTED(dir) && IS_CASEFOLDED(dir))) { in dx_probe()
858 int ret = ext4fs_dirhash(dir, fname_name(fname), in dx_probe()
868 ext4_warning_inode(dir, "Unimplemented hash flags: %#06x", in dx_probe()
874 if (indirect >= ext4_dir_htree_level(dir->i_sb)) { in dx_probe()
875 ext4_warning(dir->i_sb, in dx_probe()
877 "supported value", dir->i_ino, in dx_probe()
878 ext4_dir_htree_level(dir->i_sb)); in dx_probe()
879 if (ext4_dir_htree_level(dir->i_sb) < EXT4_HTREE_LEVEL) { in dx_probe()
880 ext4_warning(dir->i_sb, "Enable large directory " in dx_probe()
889 if (dx_get_limit(entries) != dx_root_limit(dir, in dx_probe()
891 ext4_warning_inode(dir, "dx entry: limit %u != root limit %u", in dx_probe()
893 dx_root_limit(dir, root->info.info_length)); in dx_probe()
903 ext4_warning_inode(dir, in dx_probe()
932 ext4_warning_inode(dir, in dx_probe()
942 frame->bh = ext4_read_dirblock(dir, block, INDEX); in dx_probe()
951 if (dx_get_limit(entries) != dx_node_limit(dir)) { in dx_probe()
952 ext4_warning_inode(dir, in dx_probe()
954 dx_get_limit(entries), dx_node_limit(dir)); in dx_probe()
965 ext4_warning_inode(dir, in dx_probe()
1007 static int ext4_htree_next_block(struct inode *dir, __u32 hash, in ext4_htree_next_block() argument
1053 bh = ext4_read_dirblock(dir, dx_get_block(p->at), INDEX); in ext4_htree_next_block()
1071 struct inode *dir, ext4_lblk_t block, in htree_dirblock_to_tree() argument
1079 int csum = ext4_has_metadata_csum(dir->i_sb); in htree_dirblock_to_tree()
1083 bh = ext4_read_dirblock(dir, block, DIRENT_HTREE); in htree_dirblock_to_tree()
1090 dir->i_sb->s_blocksize - in htree_dirblock_to_tree()
1092 csum ? NULL : dir)); in htree_dirblock_to_tree()
1094 if (IS_ENCRYPTED(dir)) { in htree_dirblock_to_tree()
1095 err = fscrypt_prepare_readdir(dir); in htree_dirblock_to_tree()
1108 for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { in htree_dirblock_to_tree()
1109 if (ext4_check_dir_entry(dir, NULL, de, bh, in htree_dirblock_to_tree()
1111 (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) in htree_dirblock_to_tree()
1116 if (ext4_hash_in_dirent(dir)) { in htree_dirblock_to_tree()
1125 err = ext4fs_dirhash(dir, de->name, in htree_dirblock_to_tree()
1138 if (!IS_ENCRYPTED(dir)) { in htree_dirblock_to_tree()
1150 err = fscrypt_fname_disk_to_usr(dir, hinfo->hash, in htree_dirblock_to_tree()
1189 struct inode *dir; in ext4_htree_fill_tree() local
1198 dir = file_inode(dir_file); in ext4_htree_fill_tree()
1199 if (!(ext4_test_inode_flag(dir, EXT4_INODE_INDEX))) { in ext4_htree_fill_tree()
1200 if (ext4_hash_in_dirent(dir)) in ext4_htree_fill_tree()
1204 EXT4_SB(dir->i_sb)->s_def_hash_version; in ext4_htree_fill_tree()
1207 EXT4_SB(dir->i_sb)->s_hash_unsigned; in ext4_htree_fill_tree()
1208 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; in ext4_htree_fill_tree()
1209 if (ext4_has_inline_data(dir)) { in ext4_htree_fill_tree()
1211 count = ext4_inlinedir_to_tree(dir_file, dir, 0, in ext4_htree_fill_tree()
1220 count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo, in ext4_htree_fill_tree()
1227 frame = dx_probe(NULL, dir, &hinfo, frames); in ext4_htree_fill_tree()
1244 de = ext4_next_entry(de, dir->i_sb->s_blocksize); in ext4_htree_fill_tree()
1261 ret = htree_dirblock_to_tree(dir_file, dir, block, &hinfo, in ext4_htree_fill_tree()
1269 ret = ext4_htree_next_block(dir, HASH_NB_ALWAYS, in ext4_htree_fill_tree()
1295 struct inode *dir, in search_dirblock() argument
1300 return ext4_search_dir(bh, bh->b_data, dir->i_sb->s_blocksize, dir, in search_dirblock()
1312 static int dx_make_map(struct inode *dir, struct buffer_head *bh, in dx_make_map() argument
1321 int blocksize = EXT4_BLOCK_SIZE(dir->i_sb); in dx_make_map()
1323 if (ext4_has_metadata_csum(dir->i_sb)) in dx_make_map()
1327 if (ext4_check_dir_entry(dir, NULL, de, bh, base, buflen, in dx_make_map()
1331 if (ext4_hash_in_dirent(dir)) in dx_make_map()
1334 int err = ext4fs_dirhash(dir, de->name, in dx_make_map()
1394 int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, in ext4_fname_setup_ci_filename() argument
1402 if (!IS_CASEFOLDED(dir) || in ext4_fname_setup_ci_filename()
1403 (IS_ENCRYPTED(dir) && !fscrypt_has_encryption_key(dir))) { in ext4_fname_setup_ci_filename()
1412 len = utf8_casefold(dir->i_sb->s_encoding, iname, buf, EXT4_NAME_LEN); in ext4_fname_setup_ci_filename()
1420 if (!IS_ENCRYPTED(dir)) in ext4_fname_setup_ci_filename()
1426 return ext4fs_dirhash(dir, cf_name->name, cf_name->len, hinfo); in ext4_fname_setup_ci_filename()
1428 return ext4fs_dirhash(dir, iname->name, iname->len, hinfo); in ext4_fname_setup_ci_filename()
1488 struct inode *dir, struct ext4_filename *fname, in ext4_search_dir() argument
1501 ext4_match(dir, fname, de)) { in ext4_search_dir()
1504 if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf, in ext4_search_dir()
1512 dir->i_sb->s_blocksize); in ext4_search_dir()
1521 static int is_dx_internal_node(struct inode *dir, ext4_lblk_t block, in is_dx_internal_node() argument
1524 struct super_block *sb = dir->i_sb; in is_dx_internal_node()
1526 if (!is_dx(dir)) in is_dx_internal_node()
1548 static struct buffer_head *__ext4_find_entry(struct inode *dir, in __ext4_find_entry() argument
1566 sb = dir->i_sb; in __ext4_find_entry()
1571 if (ext4_has_inline_data(dir)) { in __ext4_find_entry()
1573 ret = ext4_find_inline_entry(dir, fname, res_dir, in __ext4_find_entry()
1591 if (is_dx(dir)) { in __ext4_find_entry()
1592 ret = ext4_dx_find_entry(dir, fname, res_dir); in __ext4_find_entry()
1604 nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); in __ext4_find_entry()
1609 start = EXT4_I(dir)->i_dir_start_lookup; in __ext4_find_entry()
1627 retval = ext4_bread_batch(dir, block, ra_max, in __ext4_find_entry()
1639 EXT4_ERROR_INODE_ERR(dir, EIO, in __ext4_find_entry()
1647 !is_dx_internal_node(dir, block, in __ext4_find_entry()
1649 !ext4_dirblock_csum_verify(dir, bh)) { in __ext4_find_entry()
1650 EXT4_ERROR_INODE_ERR(dir, EFSBADCRC, in __ext4_find_entry()
1658 i = search_dirblock(bh, dir, fname, in __ext4_find_entry()
1661 EXT4_I(dir)->i_dir_start_lookup = block; in __ext4_find_entry()
1681 nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); in __ext4_find_entry()
1694 static struct buffer_head *ext4_find_entry(struct inode *dir, in ext4_find_entry() argument
1703 err = ext4_fname_setup_filename(dir, d_name, 1, &fname); in ext4_find_entry()
1709 bh = __ext4_find_entry(dir, &fname, res_dir, inlined); in ext4_find_entry()
1715 static struct buffer_head *ext4_lookup_entry(struct inode *dir, in ext4_lookup_entry() argument
1723 err = ext4_fname_prepare_lookup(dir, dentry, &fname); in ext4_lookup_entry()
1729 bh = __ext4_find_entry(dir, &fname, res_dir, NULL); in ext4_lookup_entry()
1735 static struct buffer_head * ext4_dx_find_entry(struct inode *dir, in ext4_dx_find_entry() argument
1739 struct super_block * sb = dir->i_sb; in ext4_dx_find_entry()
1748 frame = dx_probe(fname, dir, NULL, frames); in ext4_dx_find_entry()
1753 bh = ext4_read_dirblock(dir, block, DIRENT_HTREE); in ext4_dx_find_entry()
1757 retval = search_dirblock(bh, dir, fname, in ext4_dx_find_entry()
1769 retval = ext4_htree_next_block(dir, fname->hinfo.hash, frame, in ext4_dx_find_entry()
1772 ext4_warning_inode(dir, in ext4_dx_find_entry()
1788 static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) in ext4_lookup() argument
1797 bh = ext4_lookup_entry(dir, dentry, &de); in ext4_lookup()
1804 if (!ext4_valid_inum(dir->i_sb, ino)) { in ext4_lookup()
1805 EXT4_ERROR_INODE(dir, "bad inode number: %u", ino); in ext4_lookup()
1808 if (unlikely(ino == dir->i_ino)) { in ext4_lookup()
1809 EXT4_ERROR_INODE(dir, "'%pd' linked to parent dir", in ext4_lookup()
1813 inode = ext4_iget(dir->i_sb, ino, EXT4_IGET_NORMAL); in ext4_lookup()
1815 EXT4_ERROR_INODE(dir, in ext4_lookup()
1820 if (!IS_ERR(inode) && IS_ENCRYPTED(dir) && in ext4_lookup()
1822 !fscrypt_has_permitted_context(dir, inode)) { in ext4_lookup()
1825 dir->i_ino, inode->i_ino); in ext4_lookup()
1831 if (IS_ENABLED(CONFIG_UNICODE) && !inode && IS_CASEFOLDED(dir)) { in ext4_lookup()
1872 dx_move_dirents(struct inode *dir, char *from, char *to, in dx_move_dirents() argument
1881 rec_len = ext4_dir_rec_len(de->name_len, dir); in dx_move_dirents()
1901 * Compact each dir entry in the range to the minimal rec_len.
1904 static struct ext4_dir_entry_2 *dx_pack_dirents(struct inode *dir, char *base, in dx_pack_dirents() argument
1914 rec_len = ext4_dir_rec_len(de->name_len, dir); in dx_pack_dirents()
1927 * Split a full leaf block to make room for a new dir entry.
1931 static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, in do_split() argument
1935 unsigned blocksize = dir->i_sb->s_blocksize; in do_split()
1948 if (ext4_has_metadata_csum(dir->i_sb)) in do_split()
1951 bh2 = ext4_append(handle, dir, &newblock); in do_split()
1959 err = ext4_journal_get_write_access(handle, dir->i_sb, *bh, in do_split()
1965 err = ext4_journal_get_write_access(handle, dir->i_sb, frame->bh, in do_split()
1974 count = dx_make_map(dir, *bh, hinfo, map); in do_split()
2010 de2 = dx_move_dirents(dir, data1, data2, map + split, count - split, in do_split()
2012 de = dx_pack_dirents(dir, data1, blocksize); in do_split()
2024 dxtrace(dx_show_leaf(dir, hinfo, (struct ext4_dir_entry_2 *) data1, in do_split()
2026 dxtrace(dx_show_leaf(dir, hinfo, (struct ext4_dir_entry_2 *) data2, in do_split()
2035 err = ext4_handle_dirty_dirblock(handle, dir, bh2); in do_split()
2038 err = ext4_handle_dirty_dx_node(handle, dir, frame->bh); in do_split()
2049 ext4_std_error(dir->i_sb, err); in do_split()
2053 int ext4_find_dest_de(struct inode *dir, struct inode *inode, in ext4_find_dest_de() argument
2060 unsigned short reclen = ext4_dir_rec_len(fname_len(fname), dir); in ext4_find_dest_de()
2068 if (ext4_check_dir_entry(dir, NULL, de, bh, in ext4_find_dest_de()
2071 if (ext4_match(dir, fname, de)) in ext4_find_dest_de()
2073 nlen = ext4_dir_rec_len(de->name_len, dir); in ext4_find_dest_de()
2087 void ext4_insert_dentry(struct inode *dir, in ext4_insert_dentry() argument
2096 nlen = ext4_dir_rec_len(de->name_len, dir); in ext4_insert_dentry()
2110 if (ext4_hash_in_dirent(dir)) { in ext4_insert_dentry()
2128 struct inode *dir, in add_dirent_to_buf() argument
2132 unsigned int blocksize = dir->i_sb->s_blocksize; in add_dirent_to_buf()
2140 err = ext4_find_dest_de(dir, inode, bh, bh->b_data, in add_dirent_to_buf()
2146 err = ext4_journal_get_write_access(handle, dir->i_sb, bh, in add_dirent_to_buf()
2149 ext4_std_error(dir->i_sb, err); in add_dirent_to_buf()
2154 ext4_insert_dentry(dir, inode, de, blocksize, fname); in add_dirent_to_buf()
2167 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); in add_dirent_to_buf()
2168 ext4_update_dx_flag(dir); in add_dirent_to_buf()
2169 inode_inc_iversion(dir); in add_dirent_to_buf()
2170 err2 = ext4_mark_inode_dirty(handle, dir); in add_dirent_to_buf()
2172 err = ext4_handle_dirty_dirblock(handle, dir, bh); in add_dirent_to_buf()
2174 ext4_std_error(dir->i_sb, err); in add_dirent_to_buf()
2178 static bool ext4_check_dx_root(struct inode *dir, struct dx_root *root) in ext4_check_dx_root() argument
2183 unsigned int blocksize = dir->i_sb->s_blocksize; in ext4_check_dx_root()
2184 char *blockend = (char *)root + dir->i_sb->s_blocksize; in ext4_check_dx_root()
2219 EXT4_ERROR_INODE(dir, "Corrupt dir, %s, running e2fsck is recommended", in ext4_check_dx_root()
2229 struct inode *dir, in make_indexed_dir() argument
2248 blocksize = dir->i_sb->s_blocksize; in make_indexed_dir()
2249 dxtrace(printk(KERN_DEBUG "Creating index: inode %lu\n", dir->i_ino)); in make_indexed_dir()
2251 retval = ext4_journal_get_write_access(handle, dir->i_sb, bh, in make_indexed_dir()
2254 ext4_std_error(dir->i_sb, retval); in make_indexed_dir()
2260 if (!ext4_check_dx_root(dir, root)) { in make_indexed_dir()
2272 bh2 = ext4_append(handle, dir, &block); in make_indexed_dir()
2277 ext4_set_inode_flag(dir, EXT4_INODE_INDEX); in make_indexed_dir()
2285 if (ext4_check_dir_entry(dir, NULL, de, bh2, data2, len, in make_indexed_dir()
2305 if (ext4_hash_in_dirent(dir)) in make_indexed_dir()
2309 EXT4_SB(dir->i_sb)->s_def_hash_version; in make_indexed_dir()
2314 dx_set_limit(entries, dx_root_limit(dir, sizeof(root->info))); in make_indexed_dir()
2319 fname->hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; in make_indexed_dir()
2320 fname->hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; in make_indexed_dir()
2323 if (!ext4_hash_in_dirent(dir)) { in make_indexed_dir()
2324 int err = ext4fs_dirhash(dir, fname_name(fname), in make_indexed_dir()
2338 retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh); in make_indexed_dir()
2341 retval = ext4_handle_dirty_dirblock(handle, dir, bh2); in make_indexed_dir()
2345 de = do_split(handle,dir, &bh2, frame, &fname->hinfo); in make_indexed_dir()
2351 retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh2); in make_indexed_dir()
2359 ext4_mark_inode_dirty(handle, dir); in make_indexed_dir()
2378 struct inode *dir = d_inode(dentry->d_parent); in ext4_add_entry() local
2392 sb = dir->i_sb; in ext4_add_entry()
2399 if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) && in ext4_add_entry()
2404 retval = ext4_fname_setup_filename(dir, &dentry->d_name, 0, &fname); in ext4_add_entry()
2408 if (ext4_has_inline_data(dir)) { in ext4_add_entry()
2409 retval = ext4_try_add_inline_entry(handle, &fname, dir, inode); in ext4_add_entry()
2418 if (is_dx(dir)) { in ext4_add_entry()
2419 retval = ext4_dx_add_entry(handle, &fname, dir, inode); in ext4_add_entry()
2424 EXT4_ERROR_INODE(dir, in ext4_add_entry()
2429 ext4_clear_inode_flag(dir, EXT4_INODE_INDEX); in ext4_add_entry()
2431 retval = ext4_mark_inode_dirty(handle, dir); in ext4_add_entry()
2435 blocks = dir->i_size >> sb->s_blocksize_bits; in ext4_add_entry()
2437 bh = ext4_read_dirblock(dir, block, DIRENT); in ext4_add_entry()
2439 bh = ext4_bread(handle, dir, block, in ext4_add_entry()
2448 retval = add_dirent_to_buf(handle, &fname, dir, inode, in ext4_add_entry()
2455 retval = make_indexed_dir(handle, &fname, dir, in ext4_add_entry()
2462 bh = ext4_append(handle, dir, &block); in ext4_add_entry()
2476 retval = add_dirent_to_buf(handle, &fname, dir, inode, de, bh); in ext4_add_entry()
2489 struct inode *dir, struct inode *inode) in ext4_dx_add_entry() argument
2494 struct super_block *sb = dir->i_sb; in ext4_dx_add_entry()
2501 frame = dx_probe(fname, dir, NULL, frames); in ext4_dx_add_entry()
2506 bh = ext4_read_dirblock(dir, dx_get_block(frame->at), DIRENT_HTREE); in ext4_dx_add_entry()
2518 err = add_dirent_to_buf(handle, fname, dir, inode, NULL, bh); in ext4_dx_add_entry()
2550 dir->i_ino, levels); in ext4_dx_add_entry()
2560 bh2 = ext4_append(handle, dir, &newblock); in ext4_dx_add_entry()
2592 dx_set_limit(entries2, dx_node_limit(dir)); in ext4_dx_add_entry()
2604 err = ext4_handle_dirty_dx_node(handle, dir, bh2); in ext4_dx_add_entry()
2608 err = ext4_handle_dirty_dx_node(handle, dir, in ext4_dx_add_entry()
2612 err = ext4_handle_dirty_dx_node(handle, dir, in ext4_dx_add_entry()
2620 dx_set_limit(entries2, dx_node_limit(dir)); in ext4_dx_add_entry()
2630 err = ext4_handle_dirty_dx_node(handle, dir, frame->bh); in ext4_dx_add_entry()
2633 err = ext4_handle_dirty_dx_node(handle, dir, bh2); in ext4_dx_add_entry()
2639 de = do_split(handle, dir, &bh, frame, &fname->hinfo); in ext4_dx_add_entry()
2644 err = add_dirent_to_buf(handle, fname, dir, inode, de, bh); in ext4_dx_add_entry()
2648 ext4_std_error(dir->i_sb, err); /* this is a no-op if err == 0 */ in ext4_dx_add_entry()
2664 int ext4_generic_delete_entry(struct inode *dir, in ext4_generic_delete_entry() argument
2672 unsigned int blocksize = dir->i_sb->s_blocksize; in ext4_generic_delete_entry()
2679 if (ext4_check_dir_entry(dir, NULL, de, bh, in ext4_generic_delete_entry()
2704 inode_inc_iversion(dir); in ext4_generic_delete_entry()
2715 struct inode *dir, in ext4_delete_entry() argument
2721 if (ext4_has_inline_data(dir)) { in ext4_delete_entry()
2723 err = ext4_delete_inline_entry(handle, dir, de_del, bh, in ext4_delete_entry()
2729 if (ext4_has_metadata_csum(dir->i_sb)) in ext4_delete_entry()
2733 err = ext4_journal_get_write_access(handle, dir->i_sb, bh, in ext4_delete_entry()
2738 err = ext4_generic_delete_entry(dir, de_del, bh, bh->b_data, in ext4_delete_entry()
2739 dir->i_sb->s_blocksize, csum_size); in ext4_delete_entry()
2744 err = ext4_handle_dirty_dirblock(handle, dir, bh); in ext4_delete_entry()
2751 ext4_std_error(dir->i_sb, err); in ext4_delete_entry()
2794 struct inode *dir = d_inode(dentry->d_parent); in ext4_add_nondir() local
2799 if (IS_DIRSYNC(dir)) in ext4_add_nondir()
2820 static int ext4_create(struct mnt_idmap *idmap, struct inode *dir, in ext4_create() argument
2827 err = dquot_initialize(dir); in ext4_create()
2831 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_create()
2834 inode = ext4_new_inode_start_handle(idmap, dir, mode, &dentry->d_name, in ext4_create()
2850 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_create()
2855 static int ext4_mknod(struct mnt_idmap *idmap, struct inode *dir, in ext4_mknod() argument
2862 err = dquot_initialize(dir); in ext4_mknod()
2866 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_mknod()
2869 inode = ext4_new_inode_start_handle(idmap, dir, mode, &dentry->d_name, in ext4_mknod()
2884 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_mknod()
2889 static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir, in ext4_tmpfile() argument
2896 err = dquot_initialize(dir); in ext4_tmpfile()
2901 inode = ext4_new_inode_start_handle(idmap, dir, mode, in ext4_tmpfile()
2904 EXT4_MAXQUOTAS_TRANS_BLOCKS(dir->i_sb) + in ext4_tmpfile()
2921 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_tmpfile()
2959 int ext4_init_new_dir(handle_t *handle, struct inode *dir, in ext4_init_new_dir() argument
2965 unsigned int blocksize = dir->i_sb->s_blocksize; in ext4_init_new_dir()
2969 if (ext4_has_metadata_csum(dir->i_sb)) in ext4_init_new_dir()
2973 err = ext4_try_create_inline_dir(handle, dir, inode); in ext4_init_new_dir()
2985 ext4_init_dot_dotdot(inode, de, blocksize, csum_size, dir->i_ino, 0); in ext4_init_new_dir()
3000 static int ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir, in ext4_mkdir() argument
3007 if (EXT4_DIR_LINK_MAX(dir)) in ext4_mkdir()
3010 err = dquot_initialize(dir); in ext4_mkdir()
3014 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_mkdir()
3017 inode = ext4_new_inode_start_handle(idmap, dir, S_IFDIR | mode, in ext4_mkdir()
3027 err = ext4_init_new_dir(handle, dir, inode); in ext4_mkdir()
3045 ext4_inc_count(dir); in ext4_mkdir()
3047 ext4_update_dx_flag(dir); in ext4_mkdir()
3048 err = ext4_mark_inode_dirty(handle, dir); in ext4_mkdir()
3053 if (IS_DIRSYNC(dir)) in ext4_mkdir()
3060 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_mkdir()
3139 static int ext4_rmdir(struct inode *dir, struct dentry *dentry) in ext4_rmdir() argument
3147 if (unlikely(ext4_forced_shutdown(dir->i_sb))) in ext4_rmdir()
3152 retval = dquot_initialize(dir); in ext4_rmdir()
3160 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); in ext4_rmdir()
3176 handle = ext4_journal_start(dir, EXT4_HT_DIR, in ext4_rmdir()
3177 EXT4_DATA_TRANS_BLOCKS(dir->i_sb)); in ext4_rmdir()
3184 if (IS_DIRSYNC(dir)) in ext4_rmdir()
3187 retval = ext4_delete_entry(handle, dir, de, bh); in ext4_rmdir()
3202 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); in ext4_rmdir()
3207 ext4_dec_count(dir); in ext4_rmdir()
3208 ext4_update_dx_flag(dir); in ext4_rmdir()
3210 retval = ext4_mark_inode_dirty(handle, dir); in ext4_rmdir()
3218 if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) in ext4_rmdir()
3228 int __ext4_unlink(struct inode *dir, const struct qstr *d_name, in __ext4_unlink() argument
3242 bh = ext4_find_entry(dir, d_name, &de, NULL); in __ext4_unlink()
3261 handle = ext4_journal_start(dir, EXT4_HT_DIR, in __ext4_unlink()
3262 EXT4_DATA_TRANS_BLOCKS(dir->i_sb)); in __ext4_unlink()
3268 if (IS_DIRSYNC(dir)) in __ext4_unlink()
3272 retval = ext4_delete_entry(handle, dir, de, bh); in __ext4_unlink()
3275 inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); in __ext4_unlink()
3276 ext4_update_dx_flag(dir); in __ext4_unlink()
3277 retval = ext4_mark_inode_dirty(handle, dir); in __ext4_unlink()
3301 static int ext4_unlink(struct inode *dir, struct dentry *dentry) in ext4_unlink() argument
3305 if (unlikely(ext4_forced_shutdown(dir->i_sb))) in ext4_unlink()
3308 trace_ext4_unlink_enter(dir, dentry); in ext4_unlink()
3313 retval = dquot_initialize(dir); in ext4_unlink()
3320 retval = __ext4_unlink(dir, &dentry->d_name, d_inode(dentry), dentry); in ext4_unlink()
3328 if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) in ext4_unlink()
3362 static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir, in ext4_symlink() argument
3372 if (unlikely(ext4_forced_shutdown(dir->i_sb))) in ext4_symlink()
3375 err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize, in ext4_symlink()
3380 err = dquot_initialize(dir); in ext4_symlink()
3390 credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_symlink()
3393 inode = ext4_new_inode_start_handle(idmap, dir, S_IFLNK|S_IRWXUGO, in ext4_symlink()
3446 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_symlink()
3453 int __ext4_link(struct inode *dir, struct inode *inode, struct dentry *dentry) in __ext4_link() argument
3458 handle = ext4_journal_start(dir, EXT4_HT_DIR, in __ext4_link()
3459 (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in __ext4_link()
3464 if (IS_DIRSYNC(dir)) in __ext4_link()
3486 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in __ext4_link()
3492 struct inode *dir, struct dentry *dentry) in ext4_link() argument
3500 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ext4_link()
3504 if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) && in ext4_link()
3505 (!projid_eq(EXT4_I(dir)->i_projid, in ext4_link()
3509 err = dquot_initialize(dir); in ext4_link()
3512 return __ext4_link(dir, inode, dentry); in ext4_link()
3518 * if it is a normal dir.
3569 struct inode *dir; member
3599 if (le32_to_cpu(ent->parent_de->inode) != ent->dir->i_ino) in ext4_rename_dir_prepare()
3602 return ext4_journal_get_write_access(handle, ent->dir->i_sb, in ext4_rename_dir_prepare()
3629 ext4_std_error(ent->dir->i_sb, retval); in ext4_rename_dir_finish()
3641 retval = ext4_journal_get_write_access(handle, ent->dir->i_sb, ent->bh, in ext4_setent()
3646 if (ext4_has_feature_filetype(ent->dir->i_sb)) in ext4_setent()
3648 inode_inc_iversion(ent->dir); in ext4_setent()
3649 inode_set_mtime_to_ts(ent->dir, inode_set_ctime_current(ent->dir)); in ext4_setent()
3650 retval = ext4_mark_inode_dirty(handle, ent->dir); in ext4_setent()
3653 retval2 = ext4_handle_dirty_dirblock(handle, ent->dir, ent->bh); in ext4_setent()
3655 ext4_std_error(ent->dir->i_sb, retval2); in ext4_setent()
3669 * old->de could have moved from under us during make indexed dir, in ext4_resetent()
3673 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, in ext4_resetent()
3680 ext4_std_error(old.dir->i_sb, retval); in ext4_resetent()
3688 static int ext4_find_delete_entry(handle_t *handle, struct inode *dir, in ext4_find_delete_entry() argument
3695 bh = ext4_find_entry(dir, d_name, &de, NULL); in ext4_find_delete_entry()
3699 retval = ext4_delete_entry(handle, dir, de, bh); in ext4_find_delete_entry()
3720 retval = ext4_find_delete_entry(handle, ent->dir, in ext4_rename_delete()
3723 retval = ext4_delete_entry(handle, ent->dir, ent->de, ent->bh); in ext4_rename_delete()
3725 retval = ext4_find_delete_entry(handle, ent->dir, in ext4_rename_delete()
3731 ext4_warning_inode(ent->dir, in ext4_rename_delete()
3733 ent->dir->i_nlink, retval); in ext4_rename_delete()
3741 ext4_dec_count(ent->dir); in ext4_update_dir_count()
3743 ext4_inc_count(ent->dir); in ext4_update_dir_count()
3744 ext4_mark_inode_dirty(handle, ent->dir); in ext4_update_dir_count()
3760 credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS(ent->dir->i_sb) + in ext4_whiteout_for_rename()
3763 wh = ext4_new_inode_start_handle(idmap, ent->dir, in ext4_whiteout_for_rename()
3773 ext4_should_retry_alloc(ent->dir->i_sb, &retries)) in ext4_whiteout_for_rename()
3797 .dir = old_dir, in ext4_rename()
3802 .dir = new_dir, in ext4_rename()
3823 retval = dquot_initialize(old.dir); in ext4_rename()
3829 retval = dquot_initialize(new.dir); in ext4_rename()
3841 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, in ext4_rename()
3856 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, in ext4_rename()
3869 if (new.inode && !test_opt(new.dir->i_sb, NO_AUTO_DA_ALLOC)) in ext4_rename()
3872 credits = (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) + in ext4_rename()
3875 handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits); in ext4_rename()
3889 if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir)) in ext4_rename()
3899 if (new.dir != old.dir && EXT4_DIR_LINK_MAX(new.dir)) in ext4_rename()
3902 retval = ext4_rename_dir_prepare(handle, &old, new.dir != old.dir); in ext4_rename()
3907 * If we're renaming a file within an inline_data dir and adding or in ext4_rename()
3913 force_reread = (new.dir->i_ino == old.dir->i_ino && in ext4_rename()
3914 ext4_test_inode_flag(new.dir, EXT4_INODE_INLINE_DATA)); in ext4_rename()
3941 force_reread = !ext4_test_inode_flag(new.dir, in ext4_rename()
3964 inode_set_mtime_to_ts(old.dir, inode_set_ctime_current(old.dir)); in ext4_rename()
3965 ext4_update_dx_flag(old.dir); in ext4_rename()
3967 retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino); in ext4_rename()
3971 ext4_dec_count(old.dir); in ext4_rename()
3978 ext4_inc_count(new.dir); in ext4_rename()
3979 ext4_update_dx_flag(new.dir); in ext4_rename()
3980 retval = ext4_mark_inode_dirty(handle, new.dir); in ext4_rename()
3985 retval = ext4_mark_inode_dirty(handle, old.dir); in ext4_rename()
4050 .dir = old_dir, in ext4_cross_rename()
4055 .dir = new_dir, in ext4_cross_rename()
4070 retval = dquot_initialize(old.dir); in ext4_cross_rename()
4073 retval = dquot_initialize(new.dir); in ext4_cross_rename()
4077 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, in ext4_cross_rename()
4091 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, in ext4_cross_rename()
4103 handle = ext4_journal_start(old.dir, EXT4_HT_DIR, in ext4_cross_rename()
4104 (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) + in ext4_cross_rename()
4112 if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir)) in ext4_cross_rename()
4116 retval = ext4_rename_dir_prepare(handle, &old, new.dir != old.dir); in ext4_cross_rename()
4121 retval = ext4_rename_dir_prepare(handle, &new, new.dir != old.dir); in ext4_cross_rename()
4130 if (old.dir != new.dir && old.is_dir != new.is_dir) { in ext4_cross_rename()
4134 if ((old.dir_nlink_delta > 0 && EXT4_DIR_LINK_MAX(old.dir)) || in ext4_cross_rename()
4135 (new.dir_nlink_delta > 0 && EXT4_DIR_LINK_MAX(new.dir))) in ext4_cross_rename()
4163 retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino); in ext4_cross_rename()
4168 retval = ext4_rename_dir_finish(handle, &new, old.dir->i_ino); in ext4_cross_rename()