Lines Matching +full:de +full:- +full:be

1 // SPDX-License-Identifier: GPL-2.0
7 * Laboratoire MASI - Institut Blaise Pascal
16 * Big-endian to little-endian byte-swapping/bitmaps by
19 * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998
61 if (unlikely(EXT4_SB(inode->i_sb)->s_max_dir_size_kb && in ext4_append()
62 ((inode->i_size >> 10) >= in ext4_append()
63 EXT4_SB(inode->i_sb)->s_max_dir_size_kb))) in ext4_append()
64 return ERR_PTR(-ENOSPC); in ext4_append()
66 *block = inode->i_size >> inode->i_sb->s_blocksize_bits; in ext4_append()
80 return ERR_PTR(-EFSCORRUPTED); in ext4_append()
86 inode->i_size += inode->i_sb->s_blocksize; in ext4_append()
87 EXT4_I(inode)->i_disksize = inode->i_size; in ext4_append()
92 err = ext4_journal_get_write_access(handle, inode->i_sb, bh, in ext4_append()
100 ext4_std_error(inode->i_sb, err); in ext4_append()
109 * block being read to be an index block, or a block containing
114 * the caller doesn't know what kind of directory block will be read,
115 * so no specific verification will be done.
134 if (block >= inode->i_size >> inode->i_blkbits) { in __ext4_read_dirblock()
137 block, inode->i_size); in __ext4_read_dirblock()
138 return ERR_PTR(-EFSCORRUPTED); in __ext4_read_dirblock()
141 if (ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_EIO)) in __ext4_read_dirblock()
142 bh = ERR_PTR(-EIO); in __ext4_read_dirblock()
146 __ext4_warning(inode->i_sb, func, line, in __ext4_read_dirblock()
149 inode->i_ino, (unsigned long)block, in __ext4_read_dirblock()
150 current->comm, PTR_ERR(bh)); in __ext4_read_dirblock()
158 return ERR_PTR(-EFSCORRUPTED); in __ext4_read_dirblock()
162 dirent = (struct ext4_dir_entry *) bh->b_data; in __ext4_read_dirblock()
167 else if (ext4_rec_len_from_disk(dirent->rec_len, in __ext4_read_dirblock()
168 inode->i_sb->s_blocksize) == in __ext4_read_dirblock()
169 inode->i_sb->s_blocksize) in __ext4_read_dirblock()
176 return ERR_PTR(-EFSCORRUPTED); in __ext4_read_dirblock()
178 if (!ext4_has_metadata_csum(inode->i_sb) || in __ext4_read_dirblock()
185 * caller is sure it should be an index block. in __ext4_read_dirblock()
189 !ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_CRC)) in __ext4_read_dirblock()
196 return ERR_PTR(-EFSBADCRC); in __ext4_read_dirblock()
201 !ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_CRC)) in __ext4_read_dirblock()
208 return ERR_PTR(-EFSBADCRC); in __ext4_read_dirblock()
242 * dirent the two low bits of the hash version will be zero. Therefore, the
243 * hash version mod 4 should never be 0. Sincerely, the paranoia department.
333 struct ext4_dir_entry_tail *t = EXT4_DIRENT_TAIL(bh->b_data, blocksize); in ext4_initialize_dirent_tail()
336 t->det_rec_len = ext4_rec_len_to_disk( in ext4_initialize_dirent_tail()
338 t->det_reserved_ft = EXT4_FT_DIR_CSUM; in ext4_initialize_dirent_tail()
350 d = (struct ext4_dir_entry *)bh->b_data; in get_dirent_tail()
351 top = (struct ext4_dir_entry *)(bh->b_data + in get_dirent_tail()
352 (EXT4_BLOCK_SIZE(inode->i_sb) - in get_dirent_tail()
354 while (d < top && d->rec_len) in get_dirent_tail()
356 le16_to_cpu(d->rec_len)); in get_dirent_tail()
363 t = EXT4_DIRENT_TAIL(bh->b_data, EXT4_BLOCK_SIZE(inode->i_sb)); in get_dirent_tail()
366 if (t->det_reserved_zero1 || in get_dirent_tail()
367 le16_to_cpu(t->det_rec_len) != sizeof(struct ext4_dir_entry_tail) || in get_dirent_tail()
368 t->det_reserved_zero2 || in get_dirent_tail()
369 t->det_reserved_ft != EXT4_FT_DIR_CSUM) in get_dirent_tail()
377 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); in ext4_dirblock_csum()
381 csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size); in ext4_dirblock_csum()
392 "No space for directory leaf checksum. Please run e2fsck -D."); in __warn_no_space_for_csum()
399 if (!ext4_has_metadata_csum(inode->i_sb)) in ext4_dirblock_csum_verify()
408 if (t->det_checksum != ext4_dirblock_csum(inode, bh->b_data, in ext4_dirblock_csum_verify()
409 (char *)t - bh->b_data)) in ext4_dirblock_csum_verify()
420 if (!ext4_has_metadata_csum(inode->i_sb)) in ext4_dirblock_csum_set()
429 t->det_checksum = ext4_dirblock_csum(inode, bh->b_data, in ext4_dirblock_csum_set()
430 (char *)t - bh->b_data); in ext4_dirblock_csum_set()
449 if (le16_to_cpu(dirent->rec_len) == EXT4_BLOCK_SIZE(inode->i_sb)) in get_dx_countlimit()
451 else if (le16_to_cpu(dirent->rec_len) == 12) { in get_dx_countlimit()
453 if (le16_to_cpu(dp->rec_len) != in get_dx_countlimit()
454 EXT4_BLOCK_SIZE(inode->i_sb) - 12) in get_dx_countlimit()
457 if (root->reserved_zero || in get_dx_countlimit()
458 root->info_length != sizeof(struct dx_root_info)) in get_dx_countlimit()
472 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); in ext4_dx_csum()
480 csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size); in ext4_dx_csum()
494 if (!ext4_has_metadata_csum(inode->i_sb)) in ext4_dx_csum_verify()
499 EXT4_ERROR_INODE(inode, "dir seems corrupt? Run e2fsck -D."); in ext4_dx_csum_verify()
502 limit = le16_to_cpu(c->limit); in ext4_dx_csum_verify()
503 count = le16_to_cpu(c->count); in ext4_dx_csum_verify()
505 EXT4_BLOCK_SIZE(inode->i_sb) - sizeof(struct dx_tail)) { in ext4_dx_csum_verify()
511 if (t->dt_checksum != ext4_dx_csum(inode, dirent, count_offset, in ext4_dx_csum_verify()
523 if (!ext4_has_metadata_csum(inode->i_sb)) in ext4_dx_csum_set()
528 EXT4_ERROR_INODE(inode, "dir seems corrupt? Run e2fsck -D."); in ext4_dx_csum_set()
531 limit = le16_to_cpu(c->limit); in ext4_dx_csum_set()
532 count = le16_to_cpu(c->count); in ext4_dx_csum_set()
534 EXT4_BLOCK_SIZE(inode->i_sb) - sizeof(struct dx_tail)) { in ext4_dx_csum_set()
540 t->dt_checksum = ext4_dx_csum(inode, dirent, count_offset, count, t); in ext4_dx_csum_set()
547 ext4_dx_csum_set(inode, (struct ext4_dir_entry *)bh->b_data); in ext4_handle_dirty_dx_node()
558 ext4_rec_len_from_disk(p->rec_len, blocksize)); in ext4_next_entry()
562 * Future: use high four bits of block for coalesce-on-delete flags
568 return le32_to_cpu(entry->block) & 0x0fffffff; in dx_get_block()
573 entry->block = cpu_to_le32(value); in dx_set_block()
578 return le32_to_cpu(entry->hash); in dx_get_hash()
583 entry->hash = cpu_to_le32(value); in dx_set_hash()
588 return le16_to_cpu(((struct dx_countlimit *) entries)->count); in dx_get_count()
593 return le16_to_cpu(((struct dx_countlimit *) entries)->limit); in dx_get_limit()
598 ((struct dx_countlimit *) entries)->count = cpu_to_le16(value); in dx_set_count()
603 ((struct dx_countlimit *) entries)->limit = cpu_to_le16(value); in dx_set_limit()
608 unsigned int entry_space = dir->i_sb->s_blocksize - in dx_root_limit()
609 ext4_dir_rec_len(1, NULL) - in dx_root_limit()
610 ext4_dir_rec_len(2, NULL) - infosize; in dx_root_limit()
612 if (ext4_has_metadata_csum(dir->i_sb)) in dx_root_limit()
613 entry_space -= sizeof(struct dx_tail); in dx_root_limit()
619 unsigned int entry_space = dir->i_sb->s_blocksize - in dx_node_limit()
622 if (ext4_has_metadata_csum(dir->i_sb)) in dx_node_limit()
623 entry_space -= sizeof(struct dx_tail); in dx_node_limit()
636 printk(KERN_CONT " %x->%lu", in dx_show_index()
652 struct ext4_dir_entry_2 *de, in dx_show_leaf() argument
656 char *base = (char *) de; in dx_show_leaf()
660 while ((char *) de < base + size) in dx_show_leaf()
662 if (de->inode) in dx_show_leaf()
673 name = de->name; in dx_show_leaf()
674 len = de->name_len; in dx_show_leaf()
677 ext4fs_dirhash(dir, de->name, in dx_show_leaf()
678 de->name_len, &h); in dx_show_leaf()
681 (unsigned) ((char *) de in dx_show_leaf()
682 - base)); in dx_show_leaf()
693 "buffer--skipping " in dx_show_leaf()
710 h.hash = EXT4_DIRENT_HASH(de); in dx_show_leaf()
712 ext4fs_dirhash(dir, de->name, in dx_show_leaf()
713 de->name_len, &h); in dx_show_leaf()
715 h.hash, (unsigned) ((char *) de in dx_show_leaf()
716 - base)); in dx_show_leaf()
721 int len = de->name_len; in dx_show_leaf()
722 char *name = de->name; in dx_show_leaf()
723 ext4fs_dirhash(dir, de->name, de->name_len, &h); in dx_show_leaf()
725 (unsigned) ((char *) de - base)); in dx_show_leaf()
728 space += ext4_dir_rec_len(de->name_len, dir); in dx_show_leaf()
731 de = ext4_next_entry(de, size); in dx_show_leaf()
740 unsigned blocksize = dir->i_sb->s_blocksize; in dx_show_entries()
749 u32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash; in dx_show_entries()
756 dx_show_entries(hinfo, dir, ((struct dx_node *) bh->b_data)->entries, levels - 1): in dx_show_entries()
758 bh->b_data, blocksize, 0); in dx_show_entries()
778 while (n--) { in htree_rep_invariant_check()
781 at--; in htree_rep_invariant_check()
785 ASSERT(at == target - 1); in htree_rep_invariant_check()
818 frame->bh = ext4_read_dirblock(dir, 0, INDEX); in dx_probe()
819 if (IS_ERR(frame->bh)) in dx_probe()
820 return (struct dx_frame *) frame->bh; in dx_probe()
822 root = (struct dx_root *) frame->bh->b_data; in dx_probe()
823 if (root->info.hash_version != DX_HASH_TEA && in dx_probe()
824 root->info.hash_version != DX_HASH_HALF_MD4 && in dx_probe()
825 root->info.hash_version != DX_HASH_LEGACY && in dx_probe()
826 root->info.hash_version != DX_HASH_SIPHASH) { in dx_probe()
828 root->info.hash_version); in dx_probe()
832 if (root->info.hash_version != DX_HASH_SIPHASH) { in dx_probe()
838 if (root->info.hash_version == DX_HASH_SIPHASH) { in dx_probe()
845 hinfo = &fname->hinfo; in dx_probe()
846 hinfo->hash_version = root->info.hash_version; in dx_probe()
847 if (hinfo->hash_version <= DX_HASH_TEA) in dx_probe()
848 hinfo->hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; in dx_probe()
849 hinfo->seed = EXT4_SB(dir->i_sb)->s_hash_seed; in dx_probe()
854 hash = hinfo->hash; in dx_probe()
856 if (root->info.unused_flags & 1) { in dx_probe()
858 root->info.unused_flags); in dx_probe()
862 indirect = root->info.indirect_levels; in dx_probe()
863 if (indirect >= ext4_dir_htree_level(dir->i_sb)) { in dx_probe()
864 ext4_warning(dir->i_sb, in dx_probe()
866 "supported value", dir->i_ino, in dx_probe()
867 ext4_dir_htree_level(dir->i_sb)); in dx_probe()
868 if (ext4_dir_htree_level(dir->i_sb) < EXT4_HTREE_LEVEL) { in dx_probe()
869 ext4_warning(dir->i_sb, "Enable large directory " in dx_probe()
875 entries = (struct dx_entry *)(((char *)&root->info) + in dx_probe()
876 root->info.info_length); in dx_probe()
879 root->info.info_length)) { in dx_probe()
882 dx_root_limit(dir, root->info.info_length)); in dx_probe()
899 q = entries + count - 1; in dx_probe()
901 m = p + (q - p) / 2; in dx_probe()
904 q = m - 1; in dx_probe()
909 htree_rep_invariant_check(entries, p, hash, count - 1); in dx_probe()
911 at = p - 1; in dx_probe()
912 dxtrace(printk(KERN_CONT " %x->%u\n", in dx_probe()
915 frame->entries = entries; in dx_probe()
916 frame->at = at; in dx_probe()
931 frame->bh = ext4_read_dirblock(dir, block, INDEX); in dx_probe()
932 if (IS_ERR(frame->bh)) { in dx_probe()
933 ret_err = (struct dx_frame *) frame->bh; in dx_probe()
934 frame->bh = NULL; in dx_probe()
938 entries = ((struct dx_node *) frame->bh->b_data)->entries; in dx_probe()
949 brelse(frame->bh); in dx_probe()
950 frame--; in dx_probe()
968 info = &((struct dx_root *)frames[0].bh->b_data)->info; in dx_release()
969 /* save local copy, "info" may be freed after brelse() */ in dx_release()
970 indirect_levels = info->indirect_levels; in dx_release()
982 * should be necessary. Whether or not the search is necessary is
993 * If start_hash is non-null, it will be filled in with the starting
1012 * nodes need to be read. in ext4_htree_next_block()
1015 if (++(p->at) < p->entries + dx_get_count(p->entries)) in ext4_htree_next_block()
1020 p--; in ext4_htree_next_block()
1030 bhash = dx_get_hash(p->at); in ext4_htree_next_block()
1041 while (num_frames--) { in ext4_htree_next_block()
1042 bh = ext4_read_dirblock(dir, dx_get_block(p->at), INDEX); in ext4_htree_next_block()
1046 brelse(p->bh); in ext4_htree_next_block()
1047 p->bh = bh; in ext4_htree_next_block()
1048 p->at = p->entries = ((struct dx_node *) bh->b_data)->entries; in ext4_htree_next_block()
1055 * This function fills a red-black tree with information from a
1065 struct ext4_dir_entry_2 *de, *top; in htree_dirblock_to_tree() local
1068 int csum = ext4_has_metadata_csum(dir->i_sb); in htree_dirblock_to_tree()
1076 de = (struct ext4_dir_entry_2 *) bh->b_data; in htree_dirblock_to_tree()
1078 top = (struct ext4_dir_entry_2 *) ((char *) de + in htree_dirblock_to_tree()
1079 dir->i_sb->s_blocksize - in htree_dirblock_to_tree()
1097 for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) { in htree_dirblock_to_tree()
1098 if (ext4_check_dir_entry(dir, NULL, de, bh, in htree_dirblock_to_tree()
1099 bh->b_data, bh->b_size, in htree_dirblock_to_tree()
1100 (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb)) in htree_dirblock_to_tree()
1101 + ((char *)de - bh->b_data))) { in htree_dirblock_to_tree()
1106 if (de->name_len && de->inode) { in htree_dirblock_to_tree()
1107 hinfo->hash = EXT4_DIRENT_HASH(de); in htree_dirblock_to_tree()
1108 hinfo->minor_hash = EXT4_DIRENT_MINOR_HASH(de); in htree_dirblock_to_tree()
1110 hinfo->hash = 0; in htree_dirblock_to_tree()
1111 hinfo->minor_hash = 0; in htree_dirblock_to_tree()
1114 ext4fs_dirhash(dir, de->name, de->name_len, hinfo); in htree_dirblock_to_tree()
1116 if ((hinfo->hash < start_hash) || in htree_dirblock_to_tree()
1117 ((hinfo->hash == start_hash) && in htree_dirblock_to_tree()
1118 (hinfo->minor_hash < start_minor_hash))) in htree_dirblock_to_tree()
1120 if (de->inode == 0) in htree_dirblock_to_tree()
1123 tmp_str.name = de->name; in htree_dirblock_to_tree()
1124 tmp_str.len = de->name_len; in htree_dirblock_to_tree()
1126 hinfo->hash, hinfo->minor_hash, de, in htree_dirblock_to_tree()
1130 struct fscrypt_str de_name = FSTR_INIT(de->name, in htree_dirblock_to_tree()
1131 de->name_len); in htree_dirblock_to_tree()
1134 err = fscrypt_fname_disk_to_usr(dir, hinfo->hash, in htree_dirblock_to_tree()
1135 hinfo->minor_hash, &de_name, in htree_dirblock_to_tree()
1142 hinfo->hash, hinfo->minor_hash, de, in htree_dirblock_to_tree()
1160 * This function fills a red-black tree with information from a
1171 struct ext4_dir_entry_2 *de; in ext4_htree_fill_tree() local
1188 EXT4_SB(dir->i_sb)->s_def_hash_version; in ext4_htree_fill_tree()
1191 EXT4_SB(dir->i_sb)->s_hash_unsigned; in ext4_htree_fill_tree()
1192 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; in ext4_htree_fill_tree()
1217 de = (struct ext4_dir_entry_2 *) frames[0].bh->b_data; in ext4_htree_fill_tree()
1218 tmp_str.name = de->name; in ext4_htree_fill_tree()
1219 tmp_str.len = de->name_len; in ext4_htree_fill_tree()
1221 de, &tmp_str); in ext4_htree_fill_tree()
1227 de = (struct ext4_dir_entry_2 *) frames[0].bh->b_data; in ext4_htree_fill_tree()
1228 de = ext4_next_entry(de, dir->i_sb->s_blocksize); in ext4_htree_fill_tree()
1229 tmp_str.name = de->name; in ext4_htree_fill_tree()
1230 tmp_str.len = de->name_len; in ext4_htree_fill_tree()
1232 de, &tmp_str); in ext4_htree_fill_tree()
1240 err = -ERESTARTSYS; in ext4_htree_fill_tree()
1244 block = dx_get_block(frame->at); in ext4_htree_fill_tree()
1284 return ext4_search_dir(bh, bh->b_data, dir->i_sb->s_blocksize, dir, in search_dirblock()
1301 struct ext4_dir_entry_2 *de = (struct ext4_dir_entry_2 *)bh->b_data; in dx_make_map() local
1302 unsigned int buflen = bh->b_size; in dx_make_map()
1303 char *base = bh->b_data; in dx_make_map()
1306 if (ext4_has_metadata_csum(dir->i_sb)) in dx_make_map()
1307 buflen -= sizeof(struct ext4_dir_entry_tail); in dx_make_map()
1309 while ((char *) de < base + buflen) { in dx_make_map()
1310 if (ext4_check_dir_entry(dir, NULL, de, bh, base, buflen, in dx_make_map()
1311 ((char *)de) - base)) in dx_make_map()
1312 return -EFSCORRUPTED; in dx_make_map()
1313 if (de->name_len && de->inode) { in dx_make_map()
1315 h.hash = EXT4_DIRENT_HASH(de); in dx_make_map()
1317 ext4fs_dirhash(dir, de->name, de->name_len, &h); in dx_make_map()
1318 map_tail--; in dx_make_map()
1319 map_tail->hash = h.hash; in dx_make_map()
1320 map_tail->offs = ((char *) de - base)>>2; in dx_make_map()
1321 map_tail->size = le16_to_cpu(de->rec_len); in dx_make_map()
1325 de = ext4_next_entry(de, dir->i_sb->s_blocksize); in dx_make_map()
1333 struct dx_map_entry *p, *q, *top = map + count - 1; in dx_sort_map()
1338 if (count - 9 < 2) /* 9, 10 -> 11 */ in dx_sort_map()
1340 for (p = top, q = p - count; q >= map; p--, q--) in dx_sort_map()
1341 if (p->hash < q->hash) in dx_sort_map()
1348 while (q-- > map) { in dx_sort_map()
1359 struct dx_entry *entries = frame->entries; in dx_insert_block()
1360 struct dx_entry *old = frame->at, *new = old + 1; in dx_insert_block()
1365 memmove(new + 1, new, (char *)(entries + count) - (char *)(new)); in dx_insert_block()
1373 * Test whether a case-insensitive directory entry matches the filename
1383 const struct super_block *sb = parent->i_sb; in ext4_ci_compare()
1384 const struct unicode_map *um = sb->s_encoding; in ext4_ci_compare()
1395 return -ENOMEM; in ext4_ci_compare()
1413 ret = -EINVAL; in ext4_ci_compare()
1414 else if (name->len != entry.len) in ext4_ci_compare()
1417 ret = !!memcmp(name->name, entry.name, entry.len); in ext4_ci_compare()
1427 struct fscrypt_str *cf_name = &name->cf_name; in ext4_fname_setup_ci_filename()
1428 struct dx_hash_info *hinfo = &name->hinfo; in ext4_fname_setup_ci_filename()
1431 if (!IS_CASEFOLDED(dir) || !dir->i_sb->s_encoding || in ext4_fname_setup_ci_filename()
1433 cf_name->name = NULL; in ext4_fname_setup_ci_filename()
1437 cf_name->name = kmalloc(EXT4_NAME_LEN, GFP_NOFS); in ext4_fname_setup_ci_filename()
1438 if (!cf_name->name) in ext4_fname_setup_ci_filename()
1439 return -ENOMEM; in ext4_fname_setup_ci_filename()
1441 len = utf8_casefold(dir->i_sb->s_encoding, in ext4_fname_setup_ci_filename()
1442 iname, cf_name->name, in ext4_fname_setup_ci_filename()
1445 kfree(cf_name->name); in ext4_fname_setup_ci_filename()
1446 cf_name->name = NULL; in ext4_fname_setup_ci_filename()
1448 cf_name->len = (unsigned) len; in ext4_fname_setup_ci_filename()
1452 hinfo->hash_version = DX_HASH_SIPHASH; in ext4_fname_setup_ci_filename()
1453 hinfo->seed = NULL; in ext4_fname_setup_ci_filename()
1454 if (cf_name->name) in ext4_fname_setup_ci_filename()
1455 ext4fs_dirhash(dir, cf_name->name, cf_name->len, hinfo); in ext4_fname_setup_ci_filename()
1457 ext4fs_dirhash(dir, iname->name, iname->len, hinfo); in ext4_fname_setup_ci_filename()
1469 struct ext4_dir_entry_2 *de) in ext4_match() argument
1473 if (!de->inode) in ext4_match()
1476 f.usr_fname = fname->usr_fname; in ext4_match()
1477 f.disk_name = fname->disk_name; in ext4_match()
1479 f.crypto_buf = fname->crypto_buf; in ext4_match()
1483 if (parent->i_sb->s_encoding && IS_CASEFOLDED(parent) && in ext4_match()
1485 if (fname->cf_name.name) { in ext4_match()
1486 struct qstr cf = {.name = fname->cf_name.name, in ext4_match()
1487 .len = fname->cf_name.len}; in ext4_match()
1489 if (fname->hinfo.hash != EXT4_DIRENT_HASH(de) || in ext4_match()
1490 fname->hinfo.minor_hash != in ext4_match()
1491 EXT4_DIRENT_MINOR_HASH(de)) { in ext4_match()
1496 return !ext4_ci_compare(parent, &cf, de->name, in ext4_match()
1497 de->name_len, true); in ext4_match()
1499 return !ext4_ci_compare(parent, fname->usr_fname, de->name, in ext4_match()
1500 de->name_len, false); in ext4_match()
1504 return fscrypt_match_name(&f, de->name, de->name_len); in ext4_match()
1508 * Returns 0 if not found, -1 on failure, and 1 on success
1514 struct ext4_dir_entry_2 * de; in ext4_search_dir() local
1518 de = (struct ext4_dir_entry_2 *)search_buf; in ext4_search_dir()
1520 while ((char *) de < dlimit - EXT4_BASE_DIR_LEN) { in ext4_search_dir()
1523 if (de->name + de->name_len <= dlimit && in ext4_search_dir()
1524 ext4_match(dir, fname, de)) { in ext4_search_dir()
1525 /* found a match - just to be sure, do in ext4_search_dir()
1527 if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf, in ext4_search_dir()
1529 return -1; in ext4_search_dir()
1530 *res_dir = de; in ext4_search_dir()
1534 de_len = ext4_rec_len_from_disk(de->rec_len, in ext4_search_dir()
1535 dir->i_sb->s_blocksize); in ext4_search_dir()
1537 return -1; in ext4_search_dir()
1539 de = (struct ext4_dir_entry_2 *) ((char *) de + de_len); in ext4_search_dir()
1545 struct ext4_dir_entry *de) in is_dx_internal_node() argument
1547 struct super_block *sb = dir->i_sb; in is_dx_internal_node()
1553 if (de->inode == 0 && in is_dx_internal_node()
1554 ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize) == in is_dx_internal_node()
1555 sb->s_blocksize) in is_dx_internal_node()
1565 * itself (as a parameter - res_dir). It does NOT read the inode of the
1566 * entry - you'll have to do that yourself if you want to.
1568 * The returned buffer_head has ->b_count elevated. The caller is expected
1580 const u8 *name = fname->usr_fname->name; in __ext4_find_entry()
1589 sb = dir->i_sb; in __ext4_find_entry()
1590 namelen = fname->usr_fname->len; in __ext4_find_entry()
1608 * "." or ".." will only be in the first block in __ext4_find_entry()
1609 * NFS may look up ".."; "." should be handled by the VFS in __ext4_find_entry()
1628 nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); in __ext4_find_entry()
1633 start = EXT4_I(dir)->i_dir_start_lookup; in __ext4_find_entry()
1640 * We deal with the read-ahead logic here. in __ext4_find_entry()
1647 ra_max = start - block; in __ext4_find_entry()
1649 ra_max = nblocks - block; in __ext4_find_entry()
1667 ret = ERR_PTR(-EIO); in __ext4_find_entry()
1672 (struct ext4_dir_entry *)bh->b_data) && in __ext4_find_entry()
1678 ret = ERR_PTR(-EFSBADCRC); in __ext4_find_entry()
1685 EXT4_I(dir)->i_dir_start_lookup = block; in __ext4_find_entry()
1703 nblocks = dir->i_size >> EXT4_BLOCK_SIZE_BITS(sb); in __ext4_find_entry()
1710 /* Clean up the read-ahead blocks */ in __ext4_find_entry()
1726 if (err == -ENOENT) in ext4_find_entry()
1747 if (err == -ENOENT) in ext4_lookup_entry()
1762 struct super_block * sb = dir->i_sb; in ext4_dx_find_entry()
1775 block = dx_get_block(frame->at); in ext4_dx_find_entry()
1786 if (retval == -1) { in ext4_dx_find_entry()
1792 retval = ext4_htree_next_block(dir, fname->hinfo.hash, frame, in ext4_dx_find_entry()
1805 dxtrace(printk(KERN_DEBUG "%s not found\n", fname->usr_fname->name)); in ext4_dx_find_entry()
1814 struct ext4_dir_entry_2 *de; in ext4_lookup() local
1817 if (dentry->d_name.len > EXT4_NAME_LEN) in ext4_lookup()
1818 return ERR_PTR(-ENAMETOOLONG); in ext4_lookup()
1820 bh = ext4_lookup_entry(dir, dentry, &de); in ext4_lookup()
1825 __u32 ino = le32_to_cpu(de->inode); in ext4_lookup()
1827 if (!ext4_valid_inum(dir->i_sb, ino)) { in ext4_lookup()
1829 return ERR_PTR(-EFSCORRUPTED); in ext4_lookup()
1831 if (unlikely(ino == dir->i_ino)) { in ext4_lookup()
1834 return ERR_PTR(-EFSCORRUPTED); in ext4_lookup()
1836 inode = ext4_iget(dir->i_sb, ino, EXT4_IGET_NORMAL); in ext4_lookup()
1837 if (inode == ERR_PTR(-ESTALE)) { in ext4_lookup()
1841 return ERR_PTR(-EFSCORRUPTED); in ext4_lookup()
1844 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) && in ext4_lookup()
1846 ext4_warning(inode->i_sb, in ext4_lookup()
1848 dir->i_ino, inode->i_ino); in ext4_lookup()
1850 return ERR_PTR(-EPERM); in ext4_lookup()
1871 struct ext4_dir_entry_2 * de; in ext4_get_parent() local
1874 bh = ext4_find_entry(d_inode(child), &dotdot_name, &de, NULL); in ext4_get_parent()
1878 return ERR_PTR(-ENOENT); in ext4_get_parent()
1879 ino = le32_to_cpu(de->inode); in ext4_get_parent()
1882 if (!ext4_valid_inum(child->d_sb, ino)) { in ext4_get_parent()
1885 return ERR_PTR(-EFSCORRUPTED); in ext4_get_parent()
1888 return d_obtain_alias(ext4_iget(child->d_sb, ino, EXT4_IGET_NORMAL)); in ext4_get_parent()
1902 while (count--) { in dx_move_dirents()
1903 struct ext4_dir_entry_2 *de = (struct ext4_dir_entry_2 *) in dx_move_dirents() local
1904 (from + (map->offs<<2)); in dx_move_dirents()
1905 rec_len = ext4_dir_rec_len(de->name_len, dir); in dx_move_dirents()
1907 memcpy (to, de, rec_len); in dx_move_dirents()
1908 ((struct ext4_dir_entry_2 *) to)->rec_len = in dx_move_dirents()
1912 de->inode = 0; in dx_move_dirents()
1913 memset(&de->name_len, 0, ext4_rec_len_from_disk(de->rec_len, in dx_move_dirents()
1914 blocksize) - in dx_move_dirents()
1921 return (struct ext4_dir_entry_2 *) (to - rec_len); in dx_move_dirents()
1931 struct ext4_dir_entry_2 *next, *to, *prev, *de = (struct ext4_dir_entry_2 *) base; in dx_pack_dirents() local
1934 prev = to = de; in dx_pack_dirents()
1935 while ((char*)de < base + blocksize) { in dx_pack_dirents()
1936 next = ext4_next_entry(de, blocksize); in dx_pack_dirents()
1937 if (de->inode && de->name_len) { in dx_pack_dirents()
1938 rec_len = ext4_dir_rec_len(de->name_len, dir); in dx_pack_dirents()
1939 if (de > to) in dx_pack_dirents()
1940 memmove(to, de, rec_len); in dx_pack_dirents()
1941 to->rec_len = ext4_rec_len_to_disk(rec_len, blocksize); in dx_pack_dirents()
1945 de = next; in dx_pack_dirents()
1953 * Returns pointer to de in block into which the new entry will be inserted.
1959 unsigned blocksize = dir->i_sb->s_blocksize; in do_split()
1966 char *data1 = (*bh)->b_data, *data2; in do_split()
1968 struct ext4_dir_entry_2 *de = NULL, *de2; in do_split() local
1972 if (ext4_has_metadata_csum(dir->i_sb)) in do_split()
1983 err = ext4_journal_get_write_access(handle, dir->i_sb, *bh, in do_split()
1988 BUFFER_TRACE(frame->bh, "get_write_access"); in do_split()
1989 err = ext4_journal_get_write_access(handle, dir->i_sb, frame->bh, in do_split()
1994 data2 = bh2->b_data; in do_split()
2003 map -= count; in do_split()
2008 for (i = count-1; i >= 0; i--) { in do_split()
2023 split = count - move; in do_split()
2028 continued = hash2 == map[split - 1].hash; in do_split()
2030 (unsigned long)dx_get_block(frame->at), in do_split()
2031 hash2, split, count-split)); in do_split()
2034 de2 = dx_move_dirents(dir, data1, data2, map + split, count - split, in do_split()
2036 de = dx_pack_dirents(dir, data1, blocksize); in do_split()
2037 de->rec_len = ext4_rec_len_to_disk(data1 + (blocksize - csum_size) - in do_split()
2038 (char *) de, in do_split()
2040 de2->rec_len = ext4_rec_len_to_disk(data2 + (blocksize - csum_size) - in do_split()
2054 if (hinfo->hash >= hash2) { in do_split()
2056 de = de2; in do_split()
2062 err = ext4_handle_dirty_dx_node(handle, dir, frame->bh); in do_split()
2066 dxtrace(dx_show_index("frame", frame->entries)); in do_split()
2067 return de; in do_split()
2073 ext4_std_error(dir->i_sb, err); in do_split()
2083 struct ext4_dir_entry_2 *de; in ext4_find_dest_de() local
2089 de = buf; in ext4_find_dest_de()
2090 top = buf + buf_size - reclen; in ext4_find_dest_de()
2091 while ((char *) de <= top) { in ext4_find_dest_de()
2092 if (ext4_check_dir_entry(dir, NULL, de, bh, in ext4_find_dest_de()
2094 return -EFSCORRUPTED; in ext4_find_dest_de()
2095 if (ext4_match(dir, fname, de)) in ext4_find_dest_de()
2096 return -EEXIST; in ext4_find_dest_de()
2097 nlen = ext4_dir_rec_len(de->name_len, dir); in ext4_find_dest_de()
2098 rlen = ext4_rec_len_from_disk(de->rec_len, buf_size); in ext4_find_dest_de()
2099 if ((de->inode ? rlen - nlen : rlen) >= reclen) in ext4_find_dest_de()
2101 de = (struct ext4_dir_entry_2 *)((char *)de + rlen); in ext4_find_dest_de()
2104 if ((char *) de > top) in ext4_find_dest_de()
2105 return -ENOSPC; in ext4_find_dest_de()
2107 *dest_de = de; in ext4_find_dest_de()
2113 struct ext4_dir_entry_2 *de, in ext4_insert_dentry() argument
2120 nlen = ext4_dir_rec_len(de->name_len, dir); in ext4_insert_dentry()
2121 rlen = ext4_rec_len_from_disk(de->rec_len, buf_size); in ext4_insert_dentry()
2122 if (de->inode) { in ext4_insert_dentry()
2124 (struct ext4_dir_entry_2 *)((char *)de + nlen); in ext4_insert_dentry()
2125 de1->rec_len = ext4_rec_len_to_disk(rlen - nlen, buf_size); in ext4_insert_dentry()
2126 de->rec_len = ext4_rec_len_to_disk(nlen, buf_size); in ext4_insert_dentry()
2127 de = de1; in ext4_insert_dentry()
2129 de->file_type = EXT4_FT_UNKNOWN; in ext4_insert_dentry()
2130 de->inode = cpu_to_le32(inode->i_ino); in ext4_insert_dentry()
2131 ext4_set_de_type(inode->i_sb, de, inode->i_mode); in ext4_insert_dentry()
2132 de->name_len = fname_len(fname); in ext4_insert_dentry()
2133 memcpy(de->name, fname_name(fname), fname_len(fname)); in ext4_insert_dentry()
2135 struct dx_hash_info *hinfo = &fname->hinfo; in ext4_insert_dentry()
2137 EXT4_DIRENT_HASHES(de)->hash = cpu_to_le32(hinfo->hash); in ext4_insert_dentry()
2138 EXT4_DIRENT_HASHES(de)->minor_hash = in ext4_insert_dentry()
2139 cpu_to_le32(hinfo->minor_hash); in ext4_insert_dentry()
2144 * Add a new entry into a directory (leaf) block. If de is non-NULL,
2145 * it points to a directory entry which is guaranteed to be large
2146 * enough for new directory entry. If de is NULL, then
2148 * space. It will return -ENOSPC if no space is available, and -EIO
2149 * and -EEXIST if directory entry already exists.
2153 struct inode *inode, struct ext4_dir_entry_2 *de, in add_dirent_to_buf() argument
2156 unsigned int blocksize = dir->i_sb->s_blocksize; in add_dirent_to_buf()
2160 if (ext4_has_metadata_csum(inode->i_sb)) in add_dirent_to_buf()
2163 if (!de) { in add_dirent_to_buf()
2164 err = ext4_find_dest_de(dir, inode, bh, bh->b_data, in add_dirent_to_buf()
2165 blocksize - csum_size, fname, &de); in add_dirent_to_buf()
2170 err = ext4_journal_get_write_access(handle, dir->i_sb, bh, in add_dirent_to_buf()
2173 ext4_std_error(dir->i_sb, err); in add_dirent_to_buf()
2178 ext4_insert_dentry(dir, inode, de, blocksize, fname); in add_dirent_to_buf()
2191 dir->i_mtime = dir->i_ctime = current_time(dir); in add_dirent_to_buf()
2198 ext4_std_error(dir->i_sb, err); in add_dirent_to_buf()
2214 struct ext4_dir_entry_2 *de, *de2; in make_indexed_dir() local
2223 if (ext4_has_metadata_csum(inode->i_sb)) in make_indexed_dir()
2226 blocksize = dir->i_sb->s_blocksize; in make_indexed_dir()
2227 dxtrace(printk(KERN_DEBUG "Creating index: inode %lu\n", dir->i_ino)); in make_indexed_dir()
2229 retval = ext4_journal_get_write_access(handle, dir->i_sb, bh, in make_indexed_dir()
2232 ext4_std_error(dir->i_sb, retval); in make_indexed_dir()
2236 root = (struct dx_root *) bh->b_data; in make_indexed_dir()
2239 fde = &root->dotdot; in make_indexed_dir()
2240 de = (struct ext4_dir_entry_2 *)((char *)fde + in make_indexed_dir()
2241 ext4_rec_len_from_disk(fde->rec_len, blocksize)); in make_indexed_dir()
2242 if ((char *) de >= (((char *) root) + blocksize)) { in make_indexed_dir()
2245 return -EFSCORRUPTED; in make_indexed_dir()
2247 len = ((char *) root) + (blocksize - csum_size) - (char *) de; in make_indexed_dir()
2256 data2 = bh2->b_data; in make_indexed_dir()
2258 memcpy(data2, de, len); in make_indexed_dir()
2259 memset(de, 0, len); /* wipe old data */ in make_indexed_dir()
2260 de = (struct ext4_dir_entry_2 *) data2; in make_indexed_dir()
2262 while ((char *)(de2 = ext4_next_entry(de, blocksize)) < top) { in make_indexed_dir()
2263 if (ext4_check_dir_entry(dir, NULL, de, bh2, data2, len, in make_indexed_dir()
2264 (data2 + (blocksize - csum_size) - in make_indexed_dir()
2265 (char *) de))) { in make_indexed_dir()
2268 return -EFSCORRUPTED; in make_indexed_dir()
2270 de = de2; in make_indexed_dir()
2272 de->rec_len = ext4_rec_len_to_disk(data2 + (blocksize - csum_size) - in make_indexed_dir()
2273 (char *) de, blocksize); in make_indexed_dir()
2279 de = (struct ext4_dir_entry_2 *) (&root->dotdot); in make_indexed_dir()
2280 de->rec_len = ext4_rec_len_to_disk( in make_indexed_dir()
2281 blocksize - ext4_dir_rec_len(2, NULL), blocksize); in make_indexed_dir()
2282 memset (&root->info, 0, sizeof(root->info)); in make_indexed_dir()
2283 root->info.info_length = sizeof(root->info); in make_indexed_dir()
2285 root->info.hash_version = DX_HASH_SIPHASH; in make_indexed_dir()
2287 root->info.hash_version = in make_indexed_dir()
2288 EXT4_SB(dir->i_sb)->s_def_hash_version; in make_indexed_dir()
2290 entries = root->entries; in make_indexed_dir()
2293 dx_set_limit(entries, dx_root_limit(dir, sizeof(root->info))); in make_indexed_dir()
2296 fname->hinfo.hash_version = root->info.hash_version; in make_indexed_dir()
2297 if (fname->hinfo.hash_version <= DX_HASH_TEA) in make_indexed_dir()
2298 fname->hinfo.hash_version += EXT4_SB(dir->i_sb)->s_hash_unsigned; in make_indexed_dir()
2299 fname->hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; in make_indexed_dir()
2304 fname_len(fname), &fname->hinfo); in make_indexed_dir()
2308 frame->entries = entries; in make_indexed_dir()
2309 frame->at = entries; in make_indexed_dir()
2310 frame->bh = bh; in make_indexed_dir()
2312 retval = ext4_handle_dirty_dx_node(handle, dir, frame->bh); in make_indexed_dir()
2319 de = do_split(handle,dir, &bh2, frame, &fname->hinfo); in make_indexed_dir()
2320 if (IS_ERR(de)) { in make_indexed_dir()
2321 retval = PTR_ERR(de); in make_indexed_dir()
2325 retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh2); in make_indexed_dir()
2345 * NOTE!! The inode part of 'de' is left at 0 - which means you
2352 struct inode *dir = d_inode(dentry->d_parent); in ext4_add_entry()
2354 struct ext4_dir_entry_2 *de; in ext4_add_entry() local
2363 if (ext4_has_metadata_csum(inode->i_sb)) in ext4_add_entry()
2366 sb = dir->i_sb; in ext4_add_entry()
2367 blocksize = sb->s_blocksize; in ext4_add_entry()
2368 if (!dentry->d_name.len) in ext4_add_entry()
2369 return -EINVAL; in ext4_add_entry()
2372 return -ENOKEY; in ext4_add_entry()
2376 sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name)) in ext4_add_entry()
2377 return -EINVAL; in ext4_add_entry()
2380 retval = ext4_fname_setup_filename(dir, &dentry->d_name, 0, &fname); in ext4_add_entry()
2402 retval = -EFSCORRUPTED; in ext4_add_entry()
2411 blocks = dir->i_size >> sb->s_blocksize_bits; in ext4_add_entry()
2426 if (retval != -ENOSPC) in ext4_add_entry()
2445 de = (struct ext4_dir_entry_2 *) bh->b_data; in ext4_add_entry()
2446 de->inode = 0; in ext4_add_entry()
2447 de->rec_len = ext4_rec_len_to_disk(blocksize - csum_size, blocksize); in ext4_add_entry()
2452 retval = add_dirent_to_buf(handle, &fname, dir, inode, de, bh); in ext4_add_entry()
2470 struct super_block *sb = dir->i_sb; in ext4_dx_add_entry()
2471 struct ext4_dir_entry_2 *de; in ext4_dx_add_entry() local
2480 entries = frame->entries; in ext4_dx_add_entry()
2481 at = frame->at; in ext4_dx_add_entry()
2482 bh = ext4_read_dirblock(dir, dx_get_block(frame->at), DIRENT_HTREE); in ext4_dx_add_entry()
2495 if (err != -ENOSPC) in ext4_dx_add_entry()
2505 int levels = frame - frames + 1; in ext4_dx_add_entry()
2513 if (dx_get_count((frame - 1)->entries) < in ext4_dx_add_entry()
2514 dx_get_limit((frame - 1)->entries)) { in ext4_dx_add_entry()
2518 frame--; /* split higher index block */ in ext4_dx_add_entry()
2519 at = frame->at; in ext4_dx_add_entry()
2520 entries = frame->entries; in ext4_dx_add_entry()
2526 dir->i_ino, levels); in ext4_dx_add_entry()
2532 err = -ENOSPC; in ext4_dx_add_entry()
2541 node2 = (struct dx_node *)(bh2->b_data); in ext4_dx_add_entry()
2542 entries2 = node2->entries; in ext4_dx_add_entry()
2543 memset(&node2->fake, 0, sizeof(struct fake_dirent)); in ext4_dx_add_entry()
2544 node2->fake.rec_len = ext4_rec_len_to_disk(sb->s_blocksize, in ext4_dx_add_entry()
2545 sb->s_blocksize); in ext4_dx_add_entry()
2546 BUFFER_TRACE(frame->bh, "get_write_access"); in ext4_dx_add_entry()
2547 err = ext4_journal_get_write_access(handle, sb, frame->bh, in ext4_dx_add_entry()
2552 unsigned icount1 = icount/2, icount2 = icount - icount1; in ext4_dx_add_entry()
2557 BUFFER_TRACE(frame->bh, "get_write_access"); /* index root */ in ext4_dx_add_entry()
2559 (frame - 1)->bh, in ext4_dx_add_entry()
2571 if (at - entries >= icount1) { in ext4_dx_add_entry()
2572 frame->at = at - entries - icount1 + entries2; in ext4_dx_add_entry()
2573 frame->entries = entries = entries2; in ext4_dx_add_entry()
2574 swap(frame->bh, bh2); in ext4_dx_add_entry()
2576 dx_insert_block((frame - 1), hash2, newblock); in ext4_dx_add_entry()
2577 dxtrace(dx_show_index("node", frame->entries)); in ext4_dx_add_entry()
2579 ((struct dx_node *) bh2->b_data)->entries)); in ext4_dx_add_entry()
2585 (frame - 1)->bh); in ext4_dx_add_entry()
2589 frame->bh); in ext4_dx_add_entry()
2601 dxroot = (struct dx_root *)frames[0].bh->b_data; in ext4_dx_add_entry()
2602 dxroot->info.indirect_levels += 1; in ext4_dx_add_entry()
2605 dxroot->info.indirect_levels)); in ext4_dx_add_entry()
2606 err = ext4_handle_dirty_dx_node(handle, dir, frame->bh); in ext4_dx_add_entry()
2615 de = do_split(handle, dir, &bh, frame, &fname->hinfo); in ext4_dx_add_entry()
2616 if (IS_ERR(de)) { in ext4_dx_add_entry()
2617 err = PTR_ERR(de); in ext4_dx_add_entry()
2620 err = add_dirent_to_buf(handle, fname, dir, inode, de, bh); in ext4_dx_add_entry()
2624 ext4_std_error(dir->i_sb, err); /* this is a no-op if err == 0 */ in ext4_dx_add_entry()
2628 /* @restart is true means htree-path has been changed, we need to in ext4_dx_add_entry()
2629 * repeat dx_probe() to find out valid htree-path in ext4_dx_add_entry()
2647 struct ext4_dir_entry_2 *de, *pde; in ext4_generic_delete_entry() local
2648 unsigned int blocksize = dir->i_sb->s_blocksize; in ext4_generic_delete_entry()
2653 de = entry_buf; in ext4_generic_delete_entry()
2654 while (i < buf_size - csum_size) { in ext4_generic_delete_entry()
2655 if (ext4_check_dir_entry(dir, NULL, de, bh, in ext4_generic_delete_entry()
2657 return -EFSCORRUPTED; in ext4_generic_delete_entry()
2658 if (de == de_del) { in ext4_generic_delete_entry()
2660 pde->rec_len = ext4_rec_len_to_disk( in ext4_generic_delete_entry()
2661 ext4_rec_len_from_disk(pde->rec_len, in ext4_generic_delete_entry()
2663 ext4_rec_len_from_disk(de->rec_len, in ext4_generic_delete_entry()
2668 memset(de, 0, ext4_rec_len_from_disk(de->rec_len, in ext4_generic_delete_entry()
2672 de->inode = 0; in ext4_generic_delete_entry()
2673 memset(&de->name_len, 0, in ext4_generic_delete_entry()
2674 ext4_rec_len_from_disk(de->rec_len, in ext4_generic_delete_entry()
2675 blocksize) - in ext4_generic_delete_entry()
2683 i += ext4_rec_len_from_disk(de->rec_len, blocksize); in ext4_generic_delete_entry()
2684 pde = de; in ext4_generic_delete_entry()
2685 de = ext4_next_entry(de, blocksize); in ext4_generic_delete_entry()
2687 return -ENOENT; in ext4_generic_delete_entry()
2705 if (ext4_has_metadata_csum(dir->i_sb)) in ext4_delete_entry()
2709 err = ext4_journal_get_write_access(handle, dir->i_sb, bh, in ext4_delete_entry()
2714 err = ext4_generic_delete_entry(dir, de_del, bh, bh->b_data, in ext4_delete_entry()
2715 dir->i_sb->s_blocksize, csum_size); in ext4_delete_entry()
2726 if (err != -ENOENT) in ext4_delete_entry()
2727 ext4_std_error(dir->i_sb, err); in ext4_delete_entry()
2734 * the 16-bit i_links_count field on disk. Directories with i_nlink == 1 mean
2738 * feature is not enabled and returned -EMLINK. The is_dx() check is a proxy
2739 * for checking S_ISDIR(inode) (since the INODE_INDEX feature will not be set
2740 * on regular files) and to avoid creating huge/slow non-HTREE directories.
2746 (inode->i_nlink > EXT4_LINK_MAX || inode->i_nlink == 2)) in ext4_inc_count()
2751 * If a directory had nlink == 1, then we should let it be 1. This indicates
2756 if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2) in ext4_dec_count()
2762 * Add non-directory inode to a directory. On success, the inode reference is
2770 struct inode *dir = d_inode(dentry->d_parent); in ext4_add_nondir()
2790 * is so far negative - it has no inode.
2806 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_create()
2809 inode = ext4_new_inode_start_handle(mnt_userns, dir, mode, &dentry->d_name, in ext4_create()
2814 inode->i_op = &ext4_file_inode_operations; in ext4_create()
2815 inode->i_fop = &ext4_file_operations; in ext4_create()
2825 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_create()
2841 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_mknod()
2844 inode = ext4_new_inode_start_handle(mnt_userns, dir, mode, &dentry->d_name, in ext4_mknod()
2849 init_special_inode(inode, inode->i_mode, rdev); in ext4_mknod()
2850 inode->i_op = &ext4_special_inode_operations; in ext4_mknod()
2859 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_mknod()
2879 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) + in ext4_tmpfile()
2884 inode->i_op = &ext4_file_inode_operations; in ext4_tmpfile()
2885 inode->i_fop = &ext4_file_operations; in ext4_tmpfile()
2896 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_tmpfile()
2906 struct ext4_dir_entry_2 *de, in ext4_init_dot_dotdot() argument
2910 de->inode = cpu_to_le32(inode->i_ino); in ext4_init_dot_dotdot()
2911 de->name_len = 1; in ext4_init_dot_dotdot()
2912 de->rec_len = ext4_rec_len_to_disk(ext4_dir_rec_len(de->name_len, NULL), in ext4_init_dot_dotdot()
2914 strcpy(de->name, "."); in ext4_init_dot_dotdot()
2915 ext4_set_de_type(inode->i_sb, de, S_IFDIR); in ext4_init_dot_dotdot()
2917 de = ext4_next_entry(de, blocksize); in ext4_init_dot_dotdot()
2918 de->inode = cpu_to_le32(parent_ino); in ext4_init_dot_dotdot()
2919 de->name_len = 2; in ext4_init_dot_dotdot()
2921 de->rec_len = ext4_rec_len_to_disk(blocksize - in ext4_init_dot_dotdot()
2925 de->rec_len = ext4_rec_len_to_disk( in ext4_init_dot_dotdot()
2926 ext4_dir_rec_len(de->name_len, NULL), in ext4_init_dot_dotdot()
2928 strcpy(de->name, ".."); in ext4_init_dot_dotdot()
2929 ext4_set_de_type(inode->i_sb, de, S_IFDIR); in ext4_init_dot_dotdot()
2931 return ext4_next_entry(de, blocksize); in ext4_init_dot_dotdot()
2938 struct ext4_dir_entry_2 *de; in ext4_init_new_dir() local
2940 unsigned int blocksize = dir->i_sb->s_blocksize; in ext4_init_new_dir()
2944 if (ext4_has_metadata_csum(dir->i_sb)) in ext4_init_new_dir()
2949 if (err < 0 && err != -ENOSPC) in ext4_init_new_dir()
2955 inode->i_size = 0; in ext4_init_new_dir()
2959 de = (struct ext4_dir_entry_2 *)dir_block->b_data; in ext4_init_new_dir()
2960 ext4_init_dot_dotdot(inode, de, blocksize, csum_size, dir->i_ino, 0); in ext4_init_new_dir()
2983 return -EMLINK; in ext4_mkdir()
2989 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_mkdir()
2993 &dentry->d_name, in ext4_mkdir()
3000 inode->i_op = &ext4_dir_inode_operations; in ext4_mkdir()
3001 inode->i_fop = &ext4_dir_operations; in ext4_mkdir()
3035 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_mkdir()
3047 struct ext4_dir_entry_2 *de; in ext4_empty_dir() local
3059 sb = inode->i_sb; in ext4_empty_dir()
3060 if (inode->i_size < ext4_dir_rec_len(1, NULL) + in ext4_empty_dir()
3065 /* The first directory block must not be a hole, in ext4_empty_dir()
3072 de = (struct ext4_dir_entry_2 *) bh->b_data; in ext4_empty_dir()
3073 if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size, in ext4_empty_dir()
3075 le32_to_cpu(de->inode) != inode->i_ino || strcmp(".", de->name)) { in ext4_empty_dir()
3080 offset = ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize); in ext4_empty_dir()
3081 de = ext4_next_entry(de, sb->s_blocksize); in ext4_empty_dir()
3082 if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size, in ext4_empty_dir()
3084 le32_to_cpu(de->inode) == 0 || strcmp("..", de->name)) { in ext4_empty_dir()
3089 offset += ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize); in ext4_empty_dir()
3090 while (offset < inode->i_size) { in ext4_empty_dir()
3091 if (!(offset & (sb->s_blocksize - 1))) { in ext4_empty_dir()
3097 offset += sb->s_blocksize; in ext4_empty_dir()
3103 de = (struct ext4_dir_entry_2 *) (bh->b_data + in ext4_empty_dir()
3104 (offset & (sb->s_blocksize - 1))); in ext4_empty_dir()
3105 if (ext4_check_dir_entry(inode, NULL, de, bh, in ext4_empty_dir()
3106 bh->b_data, bh->b_size, offset) || in ext4_empty_dir()
3107 le32_to_cpu(de->inode)) { in ext4_empty_dir()
3111 offset += ext4_rec_len_from_disk(de->rec_len, sb->s_blocksize); in ext4_empty_dir()
3122 struct ext4_dir_entry_2 *de; in ext4_rmdir() local
3125 if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) in ext4_rmdir()
3126 return -EIO; in ext4_rmdir()
3137 retval = -ENOENT; in ext4_rmdir()
3138 bh = ext4_find_entry(dir, &dentry->d_name, &de, NULL); in ext4_rmdir()
3146 retval = -EFSCORRUPTED; in ext4_rmdir()
3147 if (le32_to_cpu(de->inode) != inode->i_ino) in ext4_rmdir()
3150 retval = -ENOTEMPTY; in ext4_rmdir()
3155 EXT4_DATA_TRANS_BLOCKS(dir->i_sb)); in ext4_rmdir()
3165 retval = ext4_delete_entry(handle, dir, de, bh); in ext4_rmdir()
3171 dentry->d_name.len, dentry->d_name.name, in ext4_rmdir()
3172 inode->i_nlink); in ext4_rmdir()
3178 inode->i_size = 0; in ext4_rmdir()
3180 inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode); in ext4_rmdir()
3191 * Case-insensitiveness. Eventually we'll want avoid in ext4_rmdir()
3210 int retval = -ENOENT; in __ext4_unlink()
3212 struct ext4_dir_entry_2 *de; in __ext4_unlink() local
3215 bh = ext4_find_entry(dir, d_name, &de, NULL); in __ext4_unlink()
3220 return -ENOENT; in __ext4_unlink()
3222 if (le32_to_cpu(de->inode) != inode->i_ino) { in __ext4_unlink()
3228 if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY) in __ext4_unlink()
3238 retval = ext4_delete_entry(handle, dir, de, bh); in __ext4_unlink()
3241 dir->i_ctime = dir->i_mtime = current_time(dir); in __ext4_unlink()
3249 if (inode->i_nlink == 0) in __ext4_unlink()
3251 d_name->len, d_name->name); in __ext4_unlink()
3254 if (!inode->i_nlink) in __ext4_unlink()
3256 inode->i_ctime = current_time(inode); in __ext4_unlink()
3269 if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) in ext4_unlink()
3270 return -EIO; in ext4_unlink()
3285 EXT4_DATA_TRANS_BLOCKS(dir->i_sb)); in ext4_unlink()
3291 retval = __ext4_unlink(handle, dir, &dentry->d_name, d_inode(dentry)); in ext4_unlink()
3296 * Case-insensitiveness. Eventually we'll want avoid in ext4_unlink()
3324 err = ext4_journal_get_write_access(handle, inode->i_sb, bh, EXT4_JTR_NONE); in ext4_init_symlink_block()
3328 kaddr = (char *)bh->b_data; in ext4_init_symlink_block()
3329 memcpy(kaddr, disk_link->name, disk_link->len); in ext4_init_symlink_block()
3330 inode->i_size = disk_link->len - 1; in ext4_init_symlink_block()
3331 EXT4_I(inode)->i_disksize = inode->i_size; in ext4_init_symlink_block()
3348 if (unlikely(ext4_forced_shutdown(EXT4_SB(dir->i_sb)))) in ext4_symlink()
3349 return -EIO; in ext4_symlink()
3351 err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize, in ext4_symlink()
3366 credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in ext4_symlink()
3370 &dentry->d_name, 0, NULL, in ext4_symlink()
3384 inode->i_op = &ext4_encrypted_symlink_inode_operations; in ext4_symlink()
3387 inode->i_op = &ext4_symlink_inode_operations; in ext4_symlink()
3389 inode->i_op = &ext4_fast_symlink_inode_operations; in ext4_symlink()
3390 inode->i_link = (char *)&EXT4_I(inode)->i_data; in ext4_symlink()
3402 memcpy((char *)&EXT4_I(inode)->i_data, disk_link.name, in ext4_symlink()
3404 inode->i_size = disk_link.len - 1; in ext4_symlink()
3405 EXT4_I(inode)->i_disksize = inode->i_size; in ext4_symlink()
3421 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in ext4_symlink()
3434 (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + in __ext4_link()
3442 inode->i_ctime = current_time(inode); in __ext4_link()
3452 if (inode->i_nlink == 1) in __ext4_link()
3461 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) in __ext4_link()
3472 if (inode->i_nlink >= EXT4_LINK_MAX) in ext4_link()
3473 return -EMLINK; in ext4_link()
3480 (!projid_eq(EXT4_I(dir)->i_projid, in ext4_link()
3481 EXT4_I(old_dentry->d_inode)->i_projid))) in ext4_link()
3482 return -EXDEV; in ext4_link()
3492 * It should be the inode block if it is inlined or the 1st block
3504 struct ext4_dir_entry_2 *de; in ext4_get_first_dir_block() local
3507 /* The first directory block must not be a hole, so in ext4_get_first_dir_block()
3516 de = (struct ext4_dir_entry_2 *) bh->b_data; in ext4_get_first_dir_block()
3517 if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, in ext4_get_first_dir_block()
3518 bh->b_size, 0) || in ext4_get_first_dir_block()
3519 le32_to_cpu(de->inode) != inode->i_ino || in ext4_get_first_dir_block()
3520 strcmp(".", de->name)) { in ext4_get_first_dir_block()
3523 *retval = -EFSCORRUPTED; in ext4_get_first_dir_block()
3526 offset = ext4_rec_len_from_disk(de->rec_len, in ext4_get_first_dir_block()
3527 inode->i_sb->s_blocksize); in ext4_get_first_dir_block()
3528 de = ext4_next_entry(de, inode->i_sb->s_blocksize); in ext4_get_first_dir_block()
3529 if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, in ext4_get_first_dir_block()
3530 bh->b_size, offset) || in ext4_get_first_dir_block()
3531 le32_to_cpu(de->inode) == 0 || strcmp("..", de->name)) { in ext4_get_first_dir_block()
3534 *retval = -EFSCORRUPTED; in ext4_get_first_dir_block()
3537 *parent_de = de; in ext4_get_first_dir_block()
3555 struct ext4_dir_entry_2 *de; member
3568 ent->dir_bh = ext4_get_first_dir_block(handle, ent->inode, in ext4_rename_dir_prepare()
3569 &retval, &ent->parent_de, in ext4_rename_dir_prepare()
3570 &ent->dir_inlined); in ext4_rename_dir_prepare()
3571 if (!ent->dir_bh) in ext4_rename_dir_prepare()
3573 if (le32_to_cpu(ent->parent_de->inode) != ent->dir->i_ino) in ext4_rename_dir_prepare()
3574 return -EFSCORRUPTED; in ext4_rename_dir_prepare()
3575 BUFFER_TRACE(ent->dir_bh, "get_write_access"); in ext4_rename_dir_prepare()
3576 return ext4_journal_get_write_access(handle, ent->dir->i_sb, in ext4_rename_dir_prepare()
3577 ent->dir_bh, EXT4_JTR_NONE); in ext4_rename_dir_prepare()
3585 ent->parent_de->inode = cpu_to_le32(dir_ino); in ext4_rename_dir_finish()
3586 BUFFER_TRACE(ent->dir_bh, "call ext4_handle_dirty_metadata"); in ext4_rename_dir_finish()
3587 if (!ent->dir_inlined) { in ext4_rename_dir_finish()
3588 if (is_dx(ent->inode)) { in ext4_rename_dir_finish()
3590 ent->inode, in ext4_rename_dir_finish()
3591 ent->dir_bh); in ext4_rename_dir_finish()
3593 retval = ext4_handle_dirty_dirblock(handle, ent->inode, in ext4_rename_dir_finish()
3594 ent->dir_bh); in ext4_rename_dir_finish()
3597 retval = ext4_mark_inode_dirty(handle, ent->inode); in ext4_rename_dir_finish()
3600 ext4_std_error(ent->dir->i_sb, retval); in ext4_rename_dir_finish()
3611 BUFFER_TRACE(ent->bh, "get write access"); in ext4_setent()
3612 retval = ext4_journal_get_write_access(handle, ent->dir->i_sb, ent->bh, in ext4_setent()
3616 ent->de->inode = cpu_to_le32(ino); in ext4_setent()
3617 if (ext4_has_feature_filetype(ent->dir->i_sb)) in ext4_setent()
3618 ent->de->file_type = file_type; in ext4_setent()
3619 inode_inc_iversion(ent->dir); in ext4_setent()
3620 ent->dir->i_ctime = ent->dir->i_mtime = in ext4_setent()
3621 current_time(ent->dir); in ext4_setent()
3622 retval = ext4_mark_inode_dirty(handle, ent->dir); in ext4_setent()
3623 BUFFER_TRACE(ent->bh, "call ext4_handle_dirty_metadata"); in ext4_setent()
3624 if (!ent->inlined) { in ext4_setent()
3625 retval2 = ext4_handle_dirty_dirblock(handle, ent->dir, ent->bh); in ext4_setent()
3627 ext4_std_error(ent->dir->i_sb, retval2); in ext4_setent()
3641 * old->de could have moved from under us during make indexed dir, in ext4_resetent()
3642 * so the old->de may no longer valid and need to find it again in ext4_resetent()
3645 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL); in ext4_resetent()
3649 retval = -ENOENT; in ext4_resetent()
3651 ext4_std_error(old.dir->i_sb, retval); in ext4_resetent()
3662 int retval = -ENOENT; in ext4_find_delete_entry()
3664 struct ext4_dir_entry_2 *de; in ext4_find_delete_entry() local
3666 bh = ext4_find_entry(dir, d_name, &de, NULL); in ext4_find_delete_entry()
3670 retval = ext4_delete_entry(handle, dir, de, bh); in ext4_find_delete_entry()
3681 * ent->de could have moved from under us during htree split, so make in ext4_rename_delete()
3682 * sure that we are deleting the right entry. We might also be pointing in ext4_rename_delete()
3683 * to a stale entry in the unused part of ent->bh so just checking inum in ext4_rename_delete()
3686 if (le32_to_cpu(ent->de->inode) != ent->inode->i_ino || in ext4_rename_delete()
3687 ent->de->name_len != ent->dentry->d_name.len || in ext4_rename_delete()
3688 strncmp(ent->de->name, ent->dentry->d_name.name, in ext4_rename_delete()
3689 ent->de->name_len) || in ext4_rename_delete()
3691 retval = ext4_find_delete_entry(handle, ent->dir, in ext4_rename_delete()
3692 &ent->dentry->d_name); in ext4_rename_delete()
3694 retval = ext4_delete_entry(handle, ent->dir, ent->de, ent->bh); in ext4_rename_delete()
3695 if (retval == -ENOENT) { in ext4_rename_delete()
3696 retval = ext4_find_delete_entry(handle, ent->dir, in ext4_rename_delete()
3697 &ent->dentry->d_name); in ext4_rename_delete()
3702 ext4_warning_inode(ent->dir, in ext4_rename_delete()
3704 ent->dir->i_nlink, retval); in ext4_rename_delete()
3710 if (ent->dir_nlink_delta) { in ext4_update_dir_count()
3711 if (ent->dir_nlink_delta == -1) in ext4_update_dir_count()
3712 ext4_dec_count(ent->dir); in ext4_update_dir_count()
3714 ext4_inc_count(ent->dir); in ext4_update_dir_count()
3715 ext4_mark_inode_dirty(handle, ent->dir); in ext4_update_dir_count()
3731 credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS(ent->dir->i_sb) + in ext4_whiteout_for_rename()
3734 wh = ext4_new_inode_start_handle(mnt_userns, ent->dir, in ext4_whiteout_for_rename()
3736 &ent->dentry->d_name, 0, NULL, in ext4_whiteout_for_rename()
3743 if (PTR_ERR(wh) == -ENOSPC && in ext4_whiteout_for_rename()
3744 ext4_should_retry_alloc(ent->dir->i_sb, &retries)) in ext4_whiteout_for_rename()
3748 init_special_inode(wh, wh->i_mode, WHITEOUT_DEV); in ext4_whiteout_for_rename()
3749 wh->i_op = &ext4_special_inode_operations; in ext4_whiteout_for_rename()
3756 * higher-level routines.
3783 if (new.inode && new.inode->i_nlink == 0) { in ext4_rename()
3786 return -EFSCORRUPTED; in ext4_rename()
3790 (!projid_eq(EXT4_I(new_dir)->i_projid, in ext4_rename()
3791 EXT4_I(old_dentry->d_inode)->i_projid))) in ext4_rename()
3792 return -EXDEV; in ext4_rename()
3809 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL); in ext4_rename()
3816 * same name. Goodbye sticky bit ;-< in ext4_rename()
3818 retval = -ENOENT; in ext4_rename()
3819 if (!old.bh || le32_to_cpu(old.de->inode) != old.inode->i_ino) in ext4_rename()
3822 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, in ext4_rename()
3823 &new.de, &new.inlined); in ext4_rename()
3835 if (new.inode && !test_opt(new.dir->i_sb, NO_AUTO_DA_ALLOC)) in ext4_rename()
3838 credits = (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) + in ext4_rename()
3854 old_file_type = old.de->file_type; in ext4_rename()
3858 if (S_ISDIR(old.inode->i_mode)) { in ext4_rename()
3860 retval = -ENOTEMPTY; in ext4_rename()
3864 retval = -EMLINK; in ext4_rename()
3876 * re-read the directory, or else we end up trying to delete a dirent in ext4_rename()
3879 force_reread = (new.dir->i_ino == old.dir->i_ino && in ext4_rename()
3885 * to be still pointing to the valid old entry. in ext4_rename()
3887 retval = ext4_setent(handle, &old, whiteout->i_ino, in ext4_rename()
3902 old.inode->i_ino, old_file_type); in ext4_rename()
3914 old.inode->i_ctime = current_time(old.inode); in ext4_rename()
3928 new.inode->i_ctime = current_time(new.inode); in ext4_rename()
3930 old.dir->i_ctime = old.dir->i_mtime = current_time(old.dir); in ext4_rename()
3933 retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino); in ext4_rename()
3940 * parent, ext4_dec_count() won't work for many-linked in ext4_rename()
3955 if (S_ISDIR(old.inode->i_mode)) { in ext4_rename()
3961 ext4_fc_mark_ineligible(old.inode->i_sb, in ext4_rename()
3964 struct super_block *sb = old.inode->i_sb; in ext4_rename()
3969 !(EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY) && in ext4_rename()
3983 if (!new.inode->i_nlink) in ext4_rename()
3992 old.inode->i_ino, old_file_type); in ext4_rename()
4028 !projid_eq(EXT4_I(new_dir)->i_projid, in ext4_cross_rename()
4029 EXT4_I(old_dentry->d_inode)->i_projid)) || in ext4_cross_rename()
4031 !projid_eq(EXT4_I(old_dir)->i_projid, in ext4_cross_rename()
4032 EXT4_I(new_dentry->d_inode)->i_projid))) in ext4_cross_rename()
4033 return -EXDEV; in ext4_cross_rename()
4042 old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, in ext4_cross_rename()
4043 &old.de, &old.inlined); in ext4_cross_rename()
4050 * same name. Goodbye sticky bit ;-< in ext4_cross_rename()
4052 retval = -ENOENT; in ext4_cross_rename()
4053 if (!old.bh || le32_to_cpu(old.de->inode) != old.inode->i_ino) in ext4_cross_rename()
4056 new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, in ext4_cross_rename()
4057 &new.de, &new.inlined); in ext4_cross_rename()
4065 if (!new.bh || le32_to_cpu(new.de->inode) != new.inode->i_ino) in ext4_cross_rename()
4069 (2 * EXT4_DATA_TRANS_BLOCKS(old.dir->i_sb) + in ext4_cross_rename()
4080 if (S_ISDIR(old.inode->i_mode)) { in ext4_cross_rename()
4086 if (S_ISDIR(new.inode->i_mode)) { in ext4_cross_rename()
4095 * nlink only needs to be modified if this is a cross directory rename. in ext4_cross_rename()
4098 old.dir_nlink_delta = old.is_dir ? -1 : 1; in ext4_cross_rename()
4099 new.dir_nlink_delta = -old.dir_nlink_delta; in ext4_cross_rename()
4100 retval = -EMLINK; in ext4_cross_rename()
4106 new_file_type = new.de->file_type; in ext4_cross_rename()
4107 retval = ext4_setent(handle, &new, old.inode->i_ino, old.de->file_type); in ext4_cross_rename()
4111 retval = ext4_setent(handle, &old, new.inode->i_ino, new_file_type); in ext4_cross_rename()
4120 old.inode->i_ctime = ctime; in ext4_cross_rename()
4121 new.inode->i_ctime = ctime; in ext4_cross_rename()
4128 ext4_fc_mark_ineligible(new.inode->i_sb, in ext4_cross_rename()
4131 retval = ext4_rename_dir_finish(handle, &old, new.dir->i_ino); in ext4_cross_rename()
4136 retval = ext4_rename_dir_finish(handle, &new, old.dir->i_ino); in ext4_cross_rename()
4161 if (unlikely(ext4_forced_shutdown(EXT4_SB(old_dir->i_sb)))) in ext4_rename2()
4162 return -EIO; in ext4_rename2()
4165 return -EINVAL; in ext4_rename2()