Lines Matching refs:dir

301 static unsigned dx_root_limit(struct inode *dir, unsigned infosize);
302 static unsigned dx_node_limit(struct inode *dir);
304 struct inode *dir,
308 static int dx_make_map(struct inode *dir, struct buffer_head *bh,
312 static struct ext4_dir_entry_2 *dx_move_dirents(struct inode *dir, char *from,
315 static struct ext4_dir_entry_2 *dx_pack_dirents(struct inode *dir, char *base,
319 static int ext4_htree_next_block(struct inode *dir, __u32 hash,
323 static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
327 struct inode *dir, struct inode *inode);
608 static inline unsigned dx_root_limit(struct inode *dir, unsigned infosize) in dx_root_limit() argument
610 unsigned int entry_space = dir->i_sb->s_blocksize - in dx_root_limit()
614 if (ext4_has_metadata_csum(dir->i_sb)) in dx_root_limit()
619 static inline unsigned dx_node_limit(struct inode *dir) in dx_node_limit() argument
621 unsigned int entry_space = dir->i_sb->s_blocksize - in dx_node_limit()
622 ext4_dir_rec_len(0, dir); in dx_node_limit()
624 if (ext4_has_metadata_csum(dir->i_sb)) in dx_node_limit()
652 static struct stats dx_show_leaf(struct inode *dir, in dx_show_leaf() argument
677 if (!IS_ENCRYPTED(dir)) { in dx_show_leaf()
679 (void) ext4fs_dirhash(dir, de->name, in dx_show_leaf()
697 res = fscrypt_fname_disk_to_usr(dir, in dx_show_leaf()
711 if (IS_CASEFOLDED(dir)) in dx_show_leaf()
714 (void) ext4fs_dirhash(dir, in dx_show_leaf()
726 (void) ext4fs_dirhash(dir, de->name, in dx_show_leaf()
732 space += ext4_dir_rec_len(de->name_len, dir); in dx_show_leaf()
741 struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir, in dx_show_entries() argument
744 unsigned blocksize = dir->i_sb->s_blocksize; in dx_show_entries()
756 bh = ext4_bread(NULL,dir, block, 0); in dx_show_entries()
760 dx_show_entries(hinfo, dir, ((struct dx_node *) bh->b_data)->entries, levels - 1): in dx_show_entries()
761 dx_show_leaf(dir, hinfo, (struct ext4_dir_entry_2 *) in dx_show_entries()
809 dx_probe(struct ext4_filename *fname, struct inode *dir, in dx_probe() argument
822 frame->bh = ext4_read_dirblock(dir, 0, INDEX); in dx_probe()
831 ext4_warning_inode(dir, "Unrecognised inode hash code %u", in dx_probe()
835 if (ext4_hash_in_dirent(dir)) { in dx_probe()
837 ext4_warning_inode(dir, in dx_probe()
843 ext4_warning_inode(dir, in dx_probe()
852 hinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; in dx_probe()
853 hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed; in dx_probe()
856 !(IS_ENCRYPTED(dir) && IS_CASEFOLDED(dir))) { in dx_probe()
857 int ret = ext4fs_dirhash(dir, fname_name(fname), in dx_probe()
867 ext4_warning_inode(dir, "Unimplemented hash flags: %#06x", in dx_probe()
873 if (indirect >= ext4_dir_htree_level(dir->i_sb)) { in dx_probe()
874 ext4_warning(dir->i_sb, in dx_probe()
876 "supported value", dir->i_ino, in dx_probe()
877 ext4_dir_htree_level(dir->i_sb)); in dx_probe()
878 if (ext4_dir_htree_level(dir->i_sb) < EXT4_HTREE_LEVEL) { in dx_probe()
879 ext4_warning(dir->i_sb, "Enable large directory " in dx_probe()
888 if (dx_get_limit(entries) != dx_root_limit(dir, in dx_probe()
890 ext4_warning_inode(dir, "dx entry: limit %u != root limit %u", in dx_probe()
892 dx_root_limit(dir, root->info.info_length)); in dx_probe()
902 ext4_warning_inode(dir, in dx_probe()
931 ext4_warning_inode(dir, in dx_probe()
941 frame->bh = ext4_read_dirblock(dir, block, INDEX); in dx_probe()
950 if (dx_get_limit(entries) != dx_node_limit(dir)) { in dx_probe()
951 ext4_warning_inode(dir, in dx_probe()
953 dx_get_limit(entries), dx_node_limit(dir)); in dx_probe()
964 ext4_warning_inode(dir, in dx_probe()
1006 static int ext4_htree_next_block(struct inode *dir, __u32 hash, in ext4_htree_next_block() argument
1052 bh = ext4_read_dirblock(dir, dx_get_block(p->at), INDEX); in ext4_htree_next_block()
1070 struct inode *dir, ext4_lblk_t block, in htree_dirblock_to_tree() argument
1078 int csum = ext4_has_metadata_csum(dir->i_sb); in htree_dirblock_to_tree()
1082 bh = ext4_read_dirblock(dir, block, DIRENT_HTREE); in htree_dirblock_to_tree()
1089 dir->i_sb->s_blocksize - in htree_dirblock_to_tree()
1091 csum ? NULL : dir)); in htree_dirblock_to_tree()
1093 if (IS_ENCRYPTED(dir)) { in htree_dirblock_to_tree()
1094 err = fscrypt_prepare_readdir(dir); in htree_dirblock_to_tree()
1107 for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { in htree_dirblock_to_tree()
1108 if (ext4_check_dir_entry(dir, NULL, de, bh, in htree_dirblock_to_tree()
1110 (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) in htree_dirblock_to_tree()
1115 if (ext4_hash_in_dirent(dir)) { in htree_dirblock_to_tree()
1124 err = ext4fs_dirhash(dir, de->name, in htree_dirblock_to_tree()
1137 if (!IS_ENCRYPTED(dir)) { in htree_dirblock_to_tree()
1149 err = fscrypt_fname_disk_to_usr(dir, hinfo->hash, in htree_dirblock_to_tree()
1188 struct inode *dir; in ext4_htree_fill_tree() local
1197 dir = file_inode(dir_file); in ext4_htree_fill_tree()
1198 if (!(ext4_test_inode_flag(dir, EXT4_INODE_INDEX))) { in ext4_htree_fill_tree()
1199 if (ext4_hash_in_dirent(dir)) in ext4_htree_fill_tree()
1203 EXT4_SB(dir->i_sb)->s_def_hash_version; in ext4_htree_fill_tree()
1206 EXT4_SB(dir->i_sb)->s_hash_unsigned; in ext4_htree_fill_tree()
1207 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; in ext4_htree_fill_tree()
1208 if (ext4_has_inline_data(dir)) { in ext4_htree_fill_tree()
1210 count = ext4_inlinedir_to_tree(dir_file, dir, 0, in ext4_htree_fill_tree()
1219 count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo, in ext4_htree_fill_tree()
1226 frame = dx_probe(NULL, dir, &hinfo, frames); in ext4_htree_fill_tree()
1243 de = ext4_next_entry(de, dir->i_sb->s_blocksize); in ext4_htree_fill_tree()
1260 ret = htree_dirblock_to_tree(dir_file, dir, block, &hinfo, in ext4_htree_fill_tree()
1268 ret = ext4_htree_next_block(dir, HASH_NB_ALWAYS, in ext4_htree_fill_tree()
1294 struct inode *dir, in search_dirblock() argument
1299 return ext4_search_dir(bh, bh->b_data, dir->i_sb->s_blocksize, dir, in search_dirblock()
1311 static int dx_make_map(struct inode *dir, struct buffer_head *bh, in dx_make_map() argument
1320 int blocksize = EXT4_BLOCK_SIZE(dir->i_sb); in dx_make_map()
1322 if (ext4_has_metadata_csum(dir->i_sb)) in dx_make_map()
1326 if (ext4_check_dir_entry(dir, NULL, de, bh, base, buflen, in dx_make_map()
1330 if (ext4_hash_in_dirent(dir)) in dx_make_map()
1333 int err = ext4fs_dirhash(dir, de->name, in dx_make_map()
1445 int ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname, in ext4_fname_setup_ci_filename() argument
1452 if (!IS_CASEFOLDED(dir) || in ext4_fname_setup_ci_filename()
1453 (IS_ENCRYPTED(dir) && !fscrypt_has_encryption_key(dir))) { in ext4_fname_setup_ci_filename()
1462 len = utf8_casefold(dir->i_sb->s_encoding, in ext4_fname_setup_ci_filename()
1470 if (!IS_ENCRYPTED(dir)) in ext4_fname_setup_ci_filename()
1476 return ext4fs_dirhash(dir, cf_name->name, cf_name->len, hinfo); in ext4_fname_setup_ci_filename()
1478 return ext4fs_dirhash(dir, iname->name, iname->len, hinfo); in ext4_fname_setup_ci_filename()
1531 struct inode *dir, struct ext4_filename *fname, in ext4_search_dir() argument
1544 ext4_match(dir, fname, de)) { in ext4_search_dir()
1547 if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf, in ext4_search_dir()
1555 dir->i_sb->s_blocksize); in ext4_search_dir()
1564 static int is_dx_internal_node(struct inode *dir, ext4_lblk_t block, in is_dx_internal_node() argument
1567 struct super_block *sb = dir->i_sb; in is_dx_internal_node()
1569 if (!is_dx(dir)) in is_dx_internal_node()
1591 static struct buffer_head *__ext4_find_entry(struct inode *dir, in __ext4_find_entry() argument
1609 sb = dir->i_sb; in __ext4_find_entry()
1614 if (ext4_has_inline_data(dir)) { in __ext4_find_entry()
1616 ret = ext4_find_inline_entry(dir, fname, res_dir, in __ext4_find_entry()
1634 if (is_dx(dir)) { in __ext4_find_entry()
1635 ret = ext4_dx_find_entry(dir, fname, res_dir); in __ext4_find_entry()
1647 nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); in __ext4_find_entry()
1652 start = EXT4_I(dir)->i_dir_start_lookup; in __ext4_find_entry()
1670 retval = ext4_bread_batch(dir, block, ra_max, in __ext4_find_entry()
1682 EXT4_ERROR_INODE_ERR(dir, EIO, in __ext4_find_entry()
1690 !is_dx_internal_node(dir, block, in __ext4_find_entry()
1692 !ext4_dirblock_csum_verify(dir, bh)) { in __ext4_find_entry()
1693 EXT4_ERROR_INODE_ERR(dir, EFSBADCRC, in __ext4_find_entry()
1701 i = search_dirblock(bh, dir, fname, in __ext4_find_entry()
1704 EXT4_I(dir)->i_dir_start_lookup = block; in __ext4_find_entry()
1722 nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); in __ext4_find_entry()
1735 static struct buffer_head *ext4_find_entry(struct inode *dir, in ext4_find_entry() argument
1744 err = ext4_fname_setup_filename(dir, d_name, 1, &fname); in ext4_find_entry()
1750 bh = __ext4_find_entry(dir, &fname, res_dir, inlined); in ext4_find_entry()
1756 static struct buffer_head *ext4_lookup_entry(struct inode *dir, in ext4_lookup_entry() argument
1764 err = ext4_fname_prepare_lookup(dir, dentry, &fname); in ext4_lookup_entry()
1771 bh = __ext4_find_entry(dir, &fname, res_dir, NULL); in ext4_lookup_entry()
1777 static struct buffer_head * ext4_dx_find_entry(struct inode *dir, in ext4_dx_find_entry() argument
1781 struct super_block * sb = dir->i_sb; in ext4_dx_find_entry()
1790 frame = dx_probe(fname, dir, NULL, frames); in ext4_dx_find_entry()
1795 bh = ext4_read_dirblock(dir, block, DIRENT_HTREE); in ext4_dx_find_entry()
1799 retval = search_dirblock(bh, dir, fname, in ext4_dx_find_entry()
1811 retval = ext4_htree_next_block(dir, fname->hinfo.hash, frame, in ext4_dx_find_entry()
1814 ext4_warning_inode(dir, in ext4_dx_find_entry()
1830 static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) in ext4_lookup() argument
1839 bh = ext4_lookup_entry(dir, dentry, &de); in ext4_lookup()
1846 if (!ext4_valid_inum(dir->i_sb, ino)) { in ext4_lookup()
1847 EXT4_ERROR_INODE(dir, "bad inode number: %u", ino); in ext4_lookup()
1850 if (unlikely(ino == dir->i_ino)) { in ext4_lookup()
1851 EXT4_ERROR_INODE(dir, "'%pd' linked to parent dir", in ext4_lookup()
1855 inode = ext4_iget(dir->i_sb, ino, EXT4_IGET_NORMAL); in ext4_lookup()
1857 EXT4_ERROR_INODE(dir, in ext4_lookup()
1862 if (!IS_ERR(inode) && IS_ENCRYPTED(dir) && in ext4_lookup()
1864 !fscrypt_has_permitted_context(dir, inode)) { in ext4_lookup()
1867 dir->i_ino, inode->i_ino); in ext4_lookup()
1874 if (!inode && IS_CASEFOLDED(dir)) { in ext4_lookup()
1915 dx_move_dirents(struct inode *dir, char *from, char *to, in dx_move_dirents() argument
1924 rec_len = ext4_dir_rec_len(de->name_len, dir); in dx_move_dirents()
1947 static struct ext4_dir_entry_2 *dx_pack_dirents(struct inode *dir, char *base, in dx_pack_dirents() argument
1957 rec_len = ext4_dir_rec_len(de->name_len, dir); in dx_pack_dirents()
1974 static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, in do_split() argument
1978 unsigned blocksize = dir->i_sb->s_blocksize; in do_split()
1991 if (ext4_has_metadata_csum(dir->i_sb)) in do_split()
1994 bh2 = ext4_append(handle, dir, &newblock); in do_split()
2002 err = ext4_journal_get_write_access(handle, dir->i_sb, *bh, in do_split()
2008 err = ext4_journal_get_write_access(handle, dir->i_sb, frame->bh, in do_split()
2017 count = dx_make_map(dir, *bh, hinfo, map); in do_split()
2053 de2 = dx_move_dirents(dir, data1, data2, map + split, count - split, in do_split()
2055 de = dx_pack_dirents(dir, data1, blocksize); in do_split()
2067 dxtrace(dx_show_leaf(dir, hinfo, (struct ext4_dir_entry_2 *) data1, in do_split()
2069 dxtrace(dx_show_leaf(dir, hinfo, (struct ext4_dir_entry_2 *) data2, in do_split()
2078 err = ext4_handle_dirty_dirblock(handle, dir, bh2); in do_split()
2081 err = ext4_handle_dirty_dx_node(handle, dir, frame->bh); in do_split()
2092 ext4_std_error(dir->i_sb, err); in do_split()
2096 int ext4_find_dest_de(struct inode *dir, struct inode *inode, in ext4_find_dest_de() argument
2103 unsigned short reclen = ext4_dir_rec_len(fname_len(fname), dir); in ext4_find_dest_de()
2111 if (ext4_check_dir_entry(dir, NULL, de, bh, in ext4_find_dest_de()
2114 if (ext4_match(dir, fname, de)) in ext4_find_dest_de()
2116 nlen = ext4_dir_rec_len(de->name_len, dir); in ext4_find_dest_de()
2130 void ext4_insert_dentry(struct inode *dir, in ext4_insert_dentry() argument
2139 nlen = ext4_dir_rec_len(de->name_len, dir); in ext4_insert_dentry()
2153 if (ext4_hash_in_dirent(dir)) { in ext4_insert_dentry()
2171 struct inode *dir, in add_dirent_to_buf() argument
2175 unsigned int blocksize = dir->i_sb->s_blocksize; in add_dirent_to_buf()
2183 err = ext4_find_dest_de(dir, inode, bh, bh->b_data, in add_dirent_to_buf()
2189 err = ext4_journal_get_write_access(handle, dir->i_sb, bh, in add_dirent_to_buf()
2192 ext4_std_error(dir->i_sb, err); in add_dirent_to_buf()
2197 ext4_insert_dentry(dir, inode, de, blocksize, fname); in add_dirent_to_buf()
2210 dir->i_mtime = inode_set_ctime_current(dir); in add_dirent_to_buf()
2211 ext4_update_dx_flag(dir); in add_dirent_to_buf()
2212 inode_inc_iversion(dir); in add_dirent_to_buf()
2213 err2 = ext4_mark_inode_dirty(handle, dir); in add_dirent_to_buf()
2215 err = ext4_handle_dirty_dirblock(handle, dir, bh); in add_dirent_to_buf()
2217 ext4_std_error(dir->i_sb, err); in add_dirent_to_buf()
2226 struct inode *dir, in make_indexed_dir() argument
2245 blocksize = dir->i_sb->s_blocksize; in make_indexed_dir()
2246 dxtrace(printk(KERN_DEBUG "Creating index: inode %lu\n", dir->i_ino)); in make_indexed_dir()
2248 retval = ext4_journal_get_write_access(handle, dir->i_sb, bh, in make_indexed_dir()
2251 ext4_std_error(dir->i_sb, retval); in make_indexed_dir()
2262 EXT4_ERROR_INODE(dir, "invalid rec_len for '..'"); in make_indexed_dir()
2269 bh2 = ext4_append(handle, dir, &block); in make_indexed_dir()
2274 ext4_set_inode_flag(dir, EXT4_INODE_INDEX); in make_indexed_dir()
2282 if (ext4_check_dir_entry(dir, NULL, de, bh2, data2, len, in make_indexed_dir()
2303 if (ext4_hash_in_dirent(dir)) in make_indexed_dir()
2307 EXT4_SB(dir->i_sb)->s_def_hash_version; in make_indexed_dir()
2312 dx_set_limit(entries, dx_root_limit(dir, sizeof(root->info))); in make_indexed_dir()
2317 fname->hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; in make_indexed_dir()
2318 fname->hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; in make_indexed_dir()
2321 if (!ext4_hash_in_dirent(dir)) { in make_indexed_dir()
2322 int err = ext4fs_dirhash(dir, fname_name(fname), in make_indexed_dir()
2336 retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh); in make_indexed_dir()
2339 retval = ext4_handle_dirty_dirblock(handle, dir, bh2); in make_indexed_dir()
2343 de = do_split(handle,dir, &bh2, frame, &fname->hinfo); in make_indexed_dir()
2349 retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh2); in make_indexed_dir()
2357 ext4_mark_inode_dirty(handle, dir); in make_indexed_dir()
2376 struct inode *dir = d_inode(dentry->d_parent); in ext4_add_entry() local
2390 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_INIT_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()
3142 static int ext4_rmdir(struct inode *dir, struct dentry *dentry) in ext4_rmdir() argument
3150 if (unlikely(ext4_forced_shutdown(dir->i_sb))) in ext4_rmdir()
3155 retval = dquot_initialize(dir); in ext4_rmdir()
3163 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); in ext4_rmdir()
3179 handle = ext4_journal_start(dir, EXT4_HT_DIR, in ext4_rmdir()
3180 EXT4_DATA_TRANS_BLOCKS(dir->i_sb)); in ext4_rmdir()
3187 if (IS_DIRSYNC(dir)) in ext4_rmdir()
3190 retval = ext4_delete_entry(handle, dir, de, bh); in ext4_rmdir()
3205 dir->i_mtime = inode_set_ctime_current(dir); in ext4_rmdir()
3210 ext4_dec_count(dir); in ext4_rmdir()
3211 ext4_update_dx_flag(dir); in ext4_rmdir()
3213 retval = ext4_mark_inode_dirty(handle, dir); in ext4_rmdir()
3222 if (IS_CASEFOLDED(dir)) in ext4_rmdir()
3233 int __ext4_unlink(struct inode *dir, const struct qstr *d_name, in __ext4_unlink() argument
3247 bh = ext4_find_entry(dir, d_name, &de, NULL); in __ext4_unlink()
3266 handle = ext4_journal_start(dir, EXT4_HT_DIR, in __ext4_unlink()
3267 EXT4_DATA_TRANS_BLOCKS(dir->i_sb)); in __ext4_unlink()
3273 if (IS_DIRSYNC(dir)) in __ext4_unlink()
3277 retval = ext4_delete_entry(handle, dir, de, bh); in __ext4_unlink()
3280 dir->i_mtime = inode_set_ctime_current(dir); in __ext4_unlink()
3281 ext4_update_dx_flag(dir); in __ext4_unlink()
3282 retval = ext4_mark_inode_dirty(handle, dir); in __ext4_unlink()
3306 static int ext4_unlink(struct inode *dir, struct dentry *dentry) in ext4_unlink() argument
3310 if (unlikely(ext4_forced_shutdown(dir->i_sb))) in ext4_unlink()
3313 trace_ext4_unlink_enter(dir, dentry); in ext4_unlink()
3318 retval = dquot_initialize(dir); in ext4_unlink()
3325 retval = __ext4_unlink(dir, &dentry->d_name, d_inode(dentry), dentry); in ext4_unlink()
3333 if (IS_CASEFOLDED(dir)) in ext4_unlink()
3368 static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir, in ext4_symlink() argument
3378 if (unlikely(ext4_forced_shutdown(dir->i_sb))) in ext4_symlink()
3381 err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize, in ext4_symlink()
3386 err = dquot_initialize(dir); in ext4_symlink()
3396 credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_symlink()
3399 inode = ext4_new_inode_start_handle(idmap, dir, S_IFLNK|S_IRWXUGO, in ext4_symlink()
3452 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_symlink()
3459 int __ext4_link(struct inode *dir, struct inode *inode, struct dentry *dentry) in __ext4_link() argument
3464 handle = ext4_journal_start(dir, EXT4_HT_DIR, in __ext4_link()
3465 (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in __ext4_link()
3470 if (IS_DIRSYNC(dir)) in __ext4_link()
3492 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in __ext4_link()
3498 struct inode *dir, struct dentry *dentry) in ext4_link() argument
3506 err = fscrypt_prepare_link(old_dentry, dir, dentry); in ext4_link()
3510 if ((ext4_test_inode_flag(dir, EXT4_INODE_PROJINHERIT)) && in ext4_link()
3511 (!projid_eq(EXT4_I(dir)->i_projid, in ext4_link()
3515 err = dquot_initialize(dir); in ext4_link()
3518 return __ext4_link(dir, inode, dentry); in ext4_link()
3578 struct inode *dir; member
3604 if (le32_to_cpu(ent->parent_de->inode) != ent->dir->i_ino) in ext4_rename_dir_prepare()
3607 return ext4_journal_get_write_access(handle, ent->dir->i_sb, in ext4_rename_dir_prepare()
3631 ext4_std_error(ent->dir->i_sb, retval); in ext4_rename_dir_finish()
3643 retval = ext4_journal_get_write_access(handle, ent->dir->i_sb, ent->bh, in ext4_setent()
3648 if (ext4_has_feature_filetype(ent->dir->i_sb)) in ext4_setent()
3650 inode_inc_iversion(ent->dir); in ext4_setent()
3651 ent->dir->i_mtime = inode_set_ctime_current(ent->dir); in ext4_setent()
3652 retval = ext4_mark_inode_dirty(handle, ent->dir); in ext4_setent()
3655 retval2 = ext4_handle_dirty_dirblock(handle, ent->dir, ent->bh); in ext4_setent()
3657 ext4_std_error(ent->dir->i_sb, retval2); in ext4_setent()
3675 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, in ext4_resetent()
3682 ext4_std_error(old.dir->i_sb, retval); in ext4_resetent()
3690 static int ext4_find_delete_entry(handle_t *handle, struct inode *dir, in ext4_find_delete_entry() argument
3697 bh = ext4_find_entry(dir, d_name, &de, NULL); in ext4_find_delete_entry()
3701 retval = ext4_delete_entry(handle, dir, de, bh); in ext4_find_delete_entry()
3722 retval = ext4_find_delete_entry(handle, ent->dir, in ext4_rename_delete()
3725 retval = ext4_delete_entry(handle, ent->dir, ent->de, ent->bh); in ext4_rename_delete()
3727 retval = ext4_find_delete_entry(handle, ent->dir, in ext4_rename_delete()
3733 ext4_warning_inode(ent->dir, in ext4_rename_delete()
3735 ent->dir->i_nlink, retval); in ext4_rename_delete()
3743 ext4_dec_count(ent->dir); in ext4_update_dir_count()
3745 ext4_inc_count(ent->dir); in ext4_update_dir_count()
3746 ext4_mark_inode_dirty(handle, ent->dir); in ext4_update_dir_count()
3762 credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS(ent->dir->i_sb) + in ext4_whiteout_for_rename()
3765 wh = ext4_new_inode_start_handle(idmap, ent->dir, in ext4_whiteout_for_rename()
3775 ext4_should_retry_alloc(ent->dir->i_sb, &retries)) in ext4_whiteout_for_rename()
3799 .dir = old_dir, in ext4_rename()
3804 .dir = new_dir, in ext4_rename()
3825 retval = dquot_initialize(old.dir); in ext4_rename()
3831 retval = dquot_initialize(new.dir); in ext4_rename()
3843 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, in ext4_rename()
3858 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, in ext4_rename()
3871 if (new.inode && !test_opt(new.dir->i_sb, NO_AUTO_DA_ALLOC)) in ext4_rename()
3874 credits = (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) + in ext4_rename()
3877 handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits); in ext4_rename()
3891 if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir)) in ext4_rename()
3901 if (new.dir != old.dir && EXT4_DIR_LINK_MAX(new.dir)) in ext4_rename()
3915 force_reread = (new.dir->i_ino == old.dir->i_ino && in ext4_rename()
3916 ext4_test_inode_flag(new.dir, EXT4_INODE_INLINE_DATA)); in ext4_rename()
3943 force_reread = !ext4_test_inode_flag(new.dir, in ext4_rename()
3966 old.dir->i_mtime = inode_set_ctime_current(old.dir); in ext4_rename()
3967 ext4_update_dx_flag(old.dir); in ext4_rename()
3969 retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino); in ext4_rename()
3973 ext4_dec_count(old.dir); in ext4_rename()
3980 ext4_inc_count(new.dir); in ext4_rename()
3981 ext4_update_dx_flag(new.dir); in ext4_rename()
3982 retval = ext4_mark_inode_dirty(handle, new.dir); in ext4_rename()
3987 retval = ext4_mark_inode_dirty(handle, old.dir); in ext4_rename()
4052 .dir = old_dir, in ext4_cross_rename()
4057 .dir = new_dir, in ext4_cross_rename()
4072 retval = dquot_initialize(old.dir); in ext4_cross_rename()
4075 retval = dquot_initialize(new.dir); in ext4_cross_rename()
4079 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, in ext4_cross_rename()
4093 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, in ext4_cross_rename()
4105 handle = ext4_journal_start(old.dir, EXT4_HT_DIR, in ext4_cross_rename()
4106 (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) + in ext4_cross_rename()
4114 if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir)) in ext4_cross_rename()
4134 if (old.dir != new.dir && old.is_dir != new.is_dir) { in ext4_cross_rename()
4138 if ((old.dir_nlink_delta > 0 && EXT4_DIR_LINK_MAX(old.dir)) || in ext4_cross_rename()
4139 (new.dir_nlink_delta > 0 && EXT4_DIR_LINK_MAX(new.dir))) in ext4_cross_rename()
4167 retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino); in ext4_cross_rename()
4172 retval = ext4_rename_dir_finish(handle, &new, old.dir->i_ino); in ext4_cross_rename()