Lines Matching defs:inode

54 					struct inode *inode,
61 if (unlikely(EXT4_SB(inode->i_sb)->s_max_dir_size_kb &&
62 ((inode->i_size >> 10) >=
63 EXT4_SB(inode->i_sb)->s_max_dir_size_kb)))
66 *block = inode->i_size >> inode->i_sb->s_blocksize_bits;
75 err = ext4_map_blocks(NULL, inode, &map, 0);
79 EXT4_ERROR_INODE(inode, "Logical block already allocated");
83 bh = ext4_bread(handle, inode, *block, EXT4_GET_BLOCKS_CREATE);
86 inode->i_size += inode->i_sb->s_blocksize;
87 EXT4_I(inode)->i_disksize = inode->i_size;
92 ext4_std_error(inode->i_sb, err);
98 static int ext4_dx_csum_verify(struct inode *inode,
115 #define ext4_read_dirblock(inode, block, type) \
116 __ext4_read_dirblock((inode), (block), (type), __func__, __LINE__)
118 static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
128 if (block >= inode->i_size >> inode->i_blkbits) {
129 ext4_error_inode(inode, func, line, block,
131 block, inode->i_size);
135 if (ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_EIO))
138 bh = ext4_bread(NULL, inode, block, 0);
140 __ext4_warning(inode->i_sb, func, line,
141 "inode #%lu: lblock %lu: comm %s: "
143 inode->i_ino, (unsigned long)block,
150 ext4_error_inode(inode, func, line, block,
159 if (is_dx(inode)) {
163 inode->i_sb->s_blocksize) ==
164 inode->i_sb->s_blocksize)
168 ext4_error_inode(inode, func, line, block,
173 if (!ext4_has_metadata_csum(inode->i_sb) ||
183 if (ext4_dx_csum_verify(inode, dirent) &&
184 !ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_CRC))
187 ext4_error_inode_err(inode, func, line, block,
195 if (ext4_dirblock_csum_verify(inode, bh) &&
196 !ext4_simulate_fail(inode->i_sb, EXT4_SIM_DIRBLOCK_CRC))
199 ext4_error_inode_err(inode, func, line, block,
221 __le32 inode;
300 static unsigned dx_root_limit(struct inode *dir, unsigned infosize);
301 static unsigned dx_node_limit(struct inode *dir);
303 struct inode *dir,
307 static int dx_make_map(struct inode *dir, struct buffer_head *bh,
316 static int ext4_htree_next_block(struct inode *dir, __u32 hash,
320 static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
324 struct inode *dir, struct inode *inode);
339 static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode,
343 int blocksize = EXT4_BLOCK_SIZE(inode->i_sb);
360 t = EXT4_DIRENT_TAIL(bh->b_data, EXT4_BLOCK_SIZE(inode->i_sb));
373 static __le32 ext4_dirblock_csum(struct inode *inode, void *dirent, int size)
375 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
376 struct ext4_inode_info *ei = EXT4_I(inode);
383 #define warn_no_space_for_csum(inode) \
384 __warn_no_space_for_csum((inode), __func__, __LINE__)
386 static void __warn_no_space_for_csum(struct inode *inode, const char *func,
389 __ext4_warning_inode(inode, func, line,
393 int ext4_dirblock_csum_verify(struct inode *inode, struct buffer_head *bh)
397 if (!ext4_has_metadata_csum(inode->i_sb))
400 t = get_dirent_tail(inode, bh);
402 warn_no_space_for_csum(inode);
406 if (t->det_checksum != ext4_dirblock_csum(inode, bh->b_data,
413 static void ext4_dirblock_csum_set(struct inode *inode,
418 if (!ext4_has_metadata_csum(inode->i_sb))
421 t = get_dirent_tail(inode, bh);
423 warn_no_space_for_csum(inode);
427 t->det_checksum = ext4_dirblock_csum(inode, bh->b_data,
432 struct inode *inode,
435 ext4_dirblock_csum_set(inode, bh);
436 return ext4_handle_dirty_metadata(handle, inode, bh);
439 static struct dx_countlimit *get_dx_countlimit(struct inode *inode,
446 int blocksize = EXT4_BLOCK_SIZE(inode->i_sb);
468 static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
471 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
472 struct ext4_inode_info *ei = EXT4_I(inode);
486 static int ext4_dx_csum_verify(struct inode *inode,
493 if (!ext4_has_metadata_csum(inode->i_sb))
496 c = get_dx_countlimit(inode, dirent, &count_offset);
498 EXT4_ERROR_INODE(inode, "dir seems corrupt? Run e2fsck -D.");
504 EXT4_BLOCK_SIZE(inode->i_sb) - sizeof(struct dx_tail)) {
505 warn_no_space_for_csum(inode);
510 if (t->dt_checksum != ext4_dx_csum(inode, dirent, count_offset,
516 static void ext4_dx_csum_set(struct inode *inode, struct ext4_dir_entry *dirent)
522 if (!ext4_has_metadata_csum(inode->i_sb))
525 c = get_dx_countlimit(inode, dirent, &count_offset);
527 EXT4_ERROR_INODE(inode, "dir seems corrupt? Run e2fsck -D.");
533 EXT4_BLOCK_SIZE(inode->i_sb) - sizeof(struct dx_tail)) {
534 warn_no_space_for_csum(inode);
539 t->dt_checksum = ext4_dx_csum(inode, dirent, count_offset, count, t);
543 struct inode *inode,
546 ext4_dx_csum_set(inode, (struct ext4_dir_entry *)bh->b_data);
547 return ext4_handle_dirty_metadata(handle, inode, bh);
605 static inline unsigned dx_root_limit(struct inode *dir, unsigned infosize)
615 static inline unsigned dx_node_limit(struct inode *dir)
647 static struct stats dx_show_leaf(struct inode *dir,
659 if (de->inode)
737 struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir,
782 dx_probe(struct ext4_filename *fname, struct inode *dir,
803 ext4_warning_inode(dir, "Unrecognised inode hash code %u",
970 static int ext4_htree_next_block(struct inode *dir, __u32 hash,
1034 struct inode *dir, ext4_lblk_t block,
1081 if (de->inode == 0)
1134 struct inode *dir;
1236 struct inode *dir,
1253 static int dx_make_map(struct inode *dir, struct buffer_head *bh,
1271 if (de->name_len && de->inode) {
1336 int ext4_ci_compare(const struct inode *parent, const struct qstr *name,
1364 void ext4_fname_setup_ci_filename(struct inode *dir, const struct qstr *iname,
1396 static inline bool ext4_match(const struct inode *parent,
1405 if (!de->inode)
1433 struct inode *dir, struct ext4_filename *fname,
1466 static int is_dx_internal_node(struct inode *dir, ext4_lblk_t block,
1475 if (de->inode == 0 &&
1487 * itself (as a parameter - res_dir). It does NOT read the inode of the
1493 static struct buffer_head *__ext4_find_entry(struct inode *dir,
1637 static struct buffer_head *ext4_find_entry(struct inode *dir,
1658 static struct buffer_head *ext4_lookup_entry(struct inode *dir,
1678 static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
1731 static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
1733 struct inode *inode;
1743 inode = NULL;
1745 __u32 ino = le32_to_cpu(de->inode);
1748 EXT4_ERROR_INODE(dir, "bad inode number: %u", ino);
1756 inode = ext4_iget(dir->i_sb, ino, EXT4_IGET_NORMAL);
1757 if (inode == ERR_PTR(-ESTALE)) {
1759 "deleted inode referenced: %u",
1763 if (!IS_ERR(inode) && IS_ENCRYPTED(dir) &&
1764 (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
1765 !fscrypt_has_permitted_context(dir, inode)) {
1766 ext4_warning(inode->i_sb,
1768 dir->i_ino, inode->i_ino);
1769 iput(inode);
1775 if (!inode && IS_CASEFOLDED(dir)) {
1784 return d_splice_alias(inode, dentry);
1800 ino = le32_to_cpu(de->inode);
1805 "bad parent inode number: %u", ino);
1831 de->inode = 0;
1855 if (de->inode && de->name_len) {
1873 static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
1993 int ext4_find_dest_de(struct inode *dir, struct inode *inode,
2015 if ((de->inode ? rlen - nlen : rlen) >= reclen)
2027 void ext4_insert_dentry(struct inode *inode,
2037 if (de->inode) {
2045 de->inode = cpu_to_le32(inode->i_ino);
2046 ext4_set_de_type(inode->i_sb, de, inode->i_mode);
2060 struct inode *dir,
2061 struct inode *inode, struct ext4_dir_entry_2 *de,
2068 if (ext4_has_metadata_csum(inode->i_sb))
2072 err = ext4_find_dest_de(dir, inode, bh, bh->b_data,
2085 ext4_insert_dentry(inode, de, blocksize, fname);
2094 * recovery deletes the inode, so the worst that can
2109 static bool ext4_check_dx_root(struct inode *dir, struct dx_root *root)
2160 struct inode *dir,
2161 struct inode *inode, struct buffer_head *bh)
2176 if (ext4_has_metadata_csum(inode->i_sb))
2180 dxtrace(printk(KERN_DEBUG "Creating index: inode %lu\n", dir->i_ino));
2268 retval = add_dirent_to_buf(handle, fname, dir, inode, de, bh2);
2288 * NOTE!! The inode part of 'de' is left at 0 - which means you
2293 struct inode *inode)
2295 struct inode *dir = d_inode(dentry->d_parent);
2306 if (ext4_has_metadata_csum(inode->i_sb))
2328 retval = ext4_try_add_inline_entry(handle, &fname, dir, inode);
2338 retval = ext4_dx_add_entry(handle, &fname, dir, inode);
2367 retval = add_dirent_to_buf(handle, &fname, dir, inode,
2375 inode, bh);
2389 de->inode = 0;
2395 retval = add_dirent_to_buf(handle, &fname, dir, inode, de, bh);
2400 ext4_set_inode_state(inode, EXT4_STATE_NEWENTRY);
2408 struct inode *dir, struct inode *inode)
2437 err = add_dirent_to_buf(handle, fname, dir, inode, NULL, bh);
2561 err = add_dirent_to_buf(handle, fname, dir, inode, de, bh);
2581 int ext4_generic_delete_entry(struct inode *dir,
2613 de->inode = 0;
2632 struct inode *dir,
2679 * for checking S_ISDIR(inode) (since the INODE_INDEX feature will not be set
2682 static void ext4_inc_count(struct inode *inode)
2684 inc_nlink(inode);
2685 if (is_dx(inode) &&
2686 (inode->i_nlink > EXT4_LINK_MAX || inode->i_nlink == 2))
2687 set_nlink(inode, 1);
2694 static void ext4_dec_count(struct inode *inode)
2696 if (!S_ISDIR(inode->i_mode) || inode->i_nlink > 2)
2697 drop_nlink(inode);
2702 * Add non-directory inode to a directory. On success, the inode reference is
2705 * inode reference in the safe context.
2708 struct dentry *dentry, struct inode **inodep)
2710 struct inode *dir = d_inode(dentry->d_parent);
2711 struct inode *inode = *inodep;
2712 int err = ext4_add_entry(handle, dentry, inode);
2714 err = ext4_mark_inode_dirty(handle, inode);
2717 d_instantiate_new(dentry, inode);
2721 drop_nlink(inode);
2722 ext4_orphan_add(handle, inode);
2723 unlock_new_inode(inode);
2730 * is so far negative - it has no inode.
2732 * If the create succeeds, we fill in the inode information
2735 static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2739 struct inode *inode;
2749 inode = ext4_new_inode_start_handle(dir, mode, &dentry->d_name, 0,
2752 err = PTR_ERR(inode);
2753 if (!IS_ERR(inode)) {
2754 inode->i_op = &ext4_file_inode_operations;
2755 inode->i_fop = &ext4_file_operations;
2756 ext4_set_aops(inode);
2757 err = ext4_add_nondir(handle, dentry, &inode);
2763 if (!IS_ERR_OR_NULL(inode))
2764 iput(inode);
2770 static int ext4_mknod(struct inode *dir, struct dentry *dentry,
2774 struct inode *inode;
2784 inode = ext4_new_inode_start_handle(dir, mode, &dentry->d_name, 0,
2787 err = PTR_ERR(inode);
2788 if (!IS_ERR(inode)) {
2789 init_special_inode(inode, inode->i_mode, rdev);
2790 inode->i_op = &ext4_special_inode_operations;
2791 err = ext4_add_nondir(handle, dentry, &inode);
2797 if (!IS_ERR_OR_NULL(inode))
2798 iput(inode);
2804 static int ext4_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
2807 struct inode *inode;
2815 inode = ext4_new_inode_start_handle(dir, mode,
2821 err = PTR_ERR(inode);
2822 if (!IS_ERR(inode)) {
2823 inode->i_op = &ext4_file_inode_operations;
2824 inode->i_fop = &ext4_file_operations;
2825 ext4_set_aops(inode);
2826 d_tmpfile(dentry, inode);
2827 err = ext4_orphan_add(handle, inode);
2830 mark_inode_dirty(inode);
2831 unlock_new_inode(inode);
2840 unlock_new_inode(inode);
2844 struct ext4_dir_entry_2 *ext4_init_dot_dotdot(struct inode *inode,
2849 de->inode = cpu_to_le32(inode->i_ino);
2854 ext4_set_de_type(inode->i_sb, de, S_IFDIR);
2857 de->inode = cpu_to_le32(parent_ino);
2867 ext4_set_de_type(inode->i_sb, de, S_IFDIR);
2872 int ext4_init_new_dir(handle_t *handle, struct inode *dir,
2873 struct inode *inode)
2885 if (ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
2886 err = ext4_try_create_inline_dir(handle, dir, inode);
2893 inode->i_size = 0;
2894 dir_block = ext4_append(handle, inode, &block);
2898 ext4_init_dot_dotdot(inode, de, blocksize, csum_size, dir->i_ino, 0);
2899 set_nlink(inode, 2);
2904 err = ext4_handle_dirty_dirblock(handle, inode, dir_block);
2913 static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
2916 struct inode *inode;
2929 inode = ext4_new_inode_start_handle(dir, S_IFDIR | mode,
2933 err = PTR_ERR(inode);
2934 if (IS_ERR(inode))
2937 inode->i_op = &ext4_dir_inode_operations;
2938 inode->i_fop = &ext4_dir_operations;
2939 err = ext4_init_new_dir(handle, dir, inode);
2942 err = ext4_mark_inode_dirty(handle, inode);
2944 err = ext4_add_entry(handle, dentry, inode);
2947 clear_nlink(inode);
2948 ext4_orphan_add(handle, inode);
2949 unlock_new_inode(inode);
2950 err2 = ext4_mark_inode_dirty(handle, inode);
2954 iput(inode);
2963 d_instantiate_new(dentry, inode);
2980 bool ext4_empty_dir(struct inode *inode)
2987 if (ext4_has_inline_data(inode)) {
2991 ret = empty_inline_dir(inode, &has_inline_data);
2996 sb = inode->i_sb;
2997 if (inode->i_size < EXT4_DIR_REC_LEN(1) + EXT4_DIR_REC_LEN(2)) {
2998 EXT4_ERROR_INODE(inode, "invalid size");
3001 bh = ext4_read_dirblock(inode, 0, EITHER);
3006 if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size,
3008 le32_to_cpu(de->inode) != inode->i_ino || strcmp(".", de->name)) {
3009 ext4_warning_inode(inode, "directory missing '.'");
3015 if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size,
3017 le32_to_cpu(de->inode) == 0 || strcmp("..", de->name)) {
3018 ext4_warning_inode(inode, "directory missing '..'");
3023 while (offset < inode->i_size) {
3028 bh = ext4_read_dirblock(inode, lblock, EITHER);
3038 if (ext4_check_dir_entry(inode, NULL, de, bh,
3040 le32_to_cpu(de->inode)) {
3051 * ext4_orphan_add() links an unlinked or truncated inode into a list of
3053 * file is closed/deleted, or in case the inode truncate spans multiple
3060 * we are just creating the inode or deleting it.
3062 int ext4_orphan_add(handle_t *handle, struct inode *inode)
3064 struct super_block *sb = inode->i_sb;
3070 if (!sbi->s_journal || is_bad_inode(inode))
3073 WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
3074 !inode_is_locked(inode));
3076 * Exit early if inode already is on orphan list. This is a big speedup
3079 if (!list_empty(&EXT4_I(inode)->i_orphan))
3085 * hold i_mutex, or the inode can not be referenced from outside,
3088 J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
3089 S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
3096 err = ext4_reserve_inode_write(handle, inode, &iloc);
3102 * Due to previous errors inode may be already a part of on-disk
3105 if (!NEXT_ORPHAN(inode) || NEXT_ORPHAN(inode) >
3107 /* Insert this inode at the head of the on-disk orphan list */
3108 NEXT_ORPHAN(inode) = le32_to_cpu(sbi->s_es->s_last_orphan);
3110 sbi->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
3115 list_add(&EXT4_I(inode)->i_orphan, &sbi->s_orphan);
3120 rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
3125 * We have to remove inode from in-memory list if
3130 list_del_init(&EXT4_I(inode)->i_orphan);
3136 jbd_debug(4, "superblock will point to %lu\n", inode->i_ino);
3137 jbd_debug(4, "orphan inode %lu will point to %d\n",
3138 inode->i_ino, NEXT_ORPHAN(inode));
3145 * ext4_orphan_del() removes an unlinked or truncated inode from the list
3148 int ext4_orphan_del(handle_t *handle, struct inode *inode)
3151 struct ext4_inode_info *ei = EXT4_I(inode);
3152 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
3160 WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
3161 !inode_is_locked(inode));
3167 /* Grab inode buffer early before taking global s_orphan_lock */
3168 err = ext4_reserve_inode_write(handle, inode, &iloc);
3172 jbd_debug(4, "remove inode %lu from orphan list\n", inode->i_ino);
3179 * disk, but we still need to remove the inode from the linked
3186 ino_next = NEXT_ORPHAN(inode);
3197 ext4_superblock_csum_set(inode->i_sb);
3203 struct inode *i_prev =
3206 jbd_debug(4, "orphan inode %lu will point to %u\n",
3219 NEXT_ORPHAN(inode) = 0;
3220 err = ext4_mark_iloc_dirty(handle, inode, &iloc);
3222 ext4_std_error(inode->i_sb, err);
3230 static int ext4_rmdir(struct inode *dir, struct dentry *dentry)
3233 struct inode *inode;
3257 inode = d_inode(dentry);
3260 if (le32_to_cpu(de->inode) != inode->i_ino)
3264 if (!ext4_empty_dir(inode))
3281 if (!EXT4_DIR_LINK_EMPTY(inode))
3282 ext4_warning_inode(inode,
3285 inode->i_nlink);
3286 inode_inc_iversion(inode);
3287 clear_nlink(inode);
3291 inode->i_size = 0;
3292 ext4_orphan_add(handle, inode);
3293 inode->i_ctime = dir->i_ctime = dir->i_mtime = current_time(inode);
3294 retval = ext4_mark_inode_dirty(handle, inode);
3320 int __ext4_unlink(struct inode *dir, const struct qstr *d_name,
3321 struct inode *inode,
3341 if (le32_to_cpu(de->inode) != inode->i_ino) {
3344 * the inode. That's because it might have gotten
3345 * renamed to a different inode number
3347 if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
3375 if (inode->i_nlink == 0)
3376 ext4_warning_inode(inode, "Deleting file '%.*s' with no links",
3379 drop_nlink(inode);
3380 if (!inode->i_nlink)
3381 ext4_orphan_add(handle, inode);
3382 inode->i_ctime = current_time(inode);
3383 retval = ext4_mark_inode_dirty(handle, inode);
3393 static int ext4_unlink(struct inode *dir, struct dentry *dentry)
3429 static int ext4_symlink(struct inode *dir,
3433 struct inode *inode;
3452 * For non-fast symlinks, we just allocate inode and put it on
3454 * group descriptor, sb, inode block, quota blocks, and
3463 * allocate new inode (bitmap, group descriptor, inode block,
3470 inode = ext4_new_inode_start_handle(dir, S_IFLNK|S_IRWXUGO,
3474 if (IS_ERR(inode)) {
3477 return PTR_ERR(inode);
3480 if (IS_ENCRYPTED(inode)) {
3481 err = fscrypt_encrypt_symlink(inode, symname, len, &disk_link);
3484 inode->i_op = &ext4_encrypted_symlink_inode_operations;
3488 if (!IS_ENCRYPTED(inode))
3489 inode->i_op = &ext4_symlink_inode_operations;
3490 inode_nohighmem(inode);
3491 ext4_set_aops(inode);
3499 * To keep fs consistent in case of crash, we have to put inode
3502 drop_nlink(inode);
3503 err = ext4_orphan_add(handle, inode);
3509 err = __page_symlink(inode, disk_link.name, disk_link.len, 1);
3513 * Now inode is being linked into dir (EXT4_DATA_TRANS_BLOCKS
3514 * + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified
3524 set_nlink(inode, 1);
3525 err = ext4_orphan_del(handle, inode);
3530 ext4_clear_inode_flag(inode, EXT4_INODE_EXTENTS);
3531 if (!IS_ENCRYPTED(inode)) {
3532 inode->i_op = &ext4_fast_symlink_inode_operations;
3533 inode->i_link = (char *)&EXT4_I(inode)->i_data;
3535 memcpy((char *)&EXT4_I(inode)->i_data, disk_link.name,
3537 inode->i_size = disk_link.len - 1;
3539 EXT4_I(inode)->i_disksize = inode->i_size;
3540 err = ext4_add_nondir(handle, dentry, &inode);
3543 if (inode)
3544 iput(inode);
3550 clear_nlink(inode);
3551 unlock_new_inode(inode);
3552 iput(inode);
3559 int __ext4_link(struct inode *dir, struct inode *inode, struct dentry *dentry)
3573 inode->i_ctime = current_time(inode);
3574 ext4_inc_count(inode);
3575 ihold(inode);
3577 err = ext4_add_entry(handle, dentry, inode);
3579 err = ext4_mark_inode_dirty(handle, inode);
3583 if (inode->i_nlink == 1)
3584 ext4_orphan_del(handle, inode);
3585 d_instantiate(dentry, inode);
3588 drop_nlink(inode);
3589 iput(inode);
3598 struct inode *dir, struct dentry *dentry)
3600 struct inode *inode = d_inode(old_dentry);
3603 if (inode->i_nlink >= EXT4_LINK_MAX)
3618 return __ext4_link(dir, inode, dentry);
3623 * It should be the inode block if it is inlined or the 1st block
3627 struct inode *inode,
3634 if (!ext4_has_inline_data(inode)) {
3638 bh = ext4_read_dirblock(inode, 0, EITHER);
3645 if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data,
3647 le32_to_cpu(de->inode) != inode->i_ino ||
3649 EXT4_ERROR_INODE(inode, "directory missing '.'");
3655 inode->i_sb->s_blocksize);
3656 de = ext4_next_entry(de, inode->i_sb->s_blocksize);
3657 if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data,
3659 le32_to_cpu(de->inode) == 0 || strcmp("..", de->name)) {
3660 EXT4_ERROR_INODE(inode, "directory missing '..'");
3671 return ext4_get_first_inline_block(inode, parent_de, retval);
3675 struct inode *dir;
3677 struct inode *inode;
3686 /* entry for ".." in inode if it's a directory */
3696 ent->dir_bh = ext4_get_first_dir_block(handle, ent->inode,
3701 if (le32_to_cpu(ent->parent_de->inode) != ent->dir->i_ino)
3712 ent->parent_de->inode = cpu_to_le32(dir_ino);
3715 if (is_dx(ent->inode)) {
3717 ent->inode,
3720 retval = ext4_handle_dirty_dirblock(handle, ent->inode,
3724 retval = ext4_mark_inode_dirty(handle, ent->inode);
3742 ent->de->inode = cpu_to_le32(ino);
3769 * before reset old inode info.
3786 static int ext4_find_delete_entry(handle_t *handle, struct inode *dir,
3813 if (le32_to_cpu(ent->de->inode) != ent->inode->i_ino ||
3846 static struct inode *ext4_whiteout_for_rename(struct ext4_renament *ent,
3849 struct inode *wh;
3854 * for inode block, sb block, group summaries,
3855 * and inode bitmap
3883 * n.b. old_{dentry,inode) refers to the source dentry/inode
3884 * while new_{dentry,inode) refers to the destination dentry/inode
3887 static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
3888 struct inode *new_dir, struct dentry *new_dentry,
3895 .inode = d_inode(old_dentry),
3900 .inode = d_inode(new_dentry),
3904 struct inode *whiteout = NULL;
3908 if (new.inode && new.inode->i_nlink == 0) {
3909 EXT4_ERROR_INODE(new.inode,
3922 retval = dquot_initialize(old.inode);
3931 if (new.inode) {
3932 retval = dquot_initialize(new.inode);
3943 * Check for inode number is _not_ due to possible IO errors.
3949 if (!old.bh || le32_to_cpu(old.de->inode) != old.inode->i_ino)
3960 if (!new.inode) {
3965 if (new.inode && !test_opt(new.dir->i_sb, NO_AUTO_DA_ALLOC))
3966 ext4_alloc_da_blocks(old.inode);
3988 if (S_ISDIR(old.inode->i_mode)) {
3989 if (new.inode) {
3991 if (!ext4_empty_dir(new.inode))
4027 retval = ext4_add_entry(handle, new.dentry, old.inode);
4032 old.inode->i_ino, old_file_type);
4044 old.inode->i_ctime = current_time(old.inode);
4045 retval = ext4_mark_inode_dirty(handle, old.inode);
4056 if (new.inode) {
4057 ext4_dec_count(new.inode);
4058 new.inode->i_ctime = current_time(new.inode);
4068 if (new.inode) {
4072 clear_nlink(new.inode);
4085 if (S_ISDIR(old.inode->i_mode)) {
4091 ext4_fc_mark_ineligible(old.inode->i_sb,
4094 if (new.inode)
4096 __ext4_fc_track_link(handle, old.inode, new.dentry);
4097 __ext4_fc_track_unlink(handle, old.inode, old.dentry);
4102 if (new.inode) {
4103 retval = ext4_mark_inode_dirty(handle, new.inode);
4106 if (!new.inode->i_nlink)
4107 ext4_orphan_add(handle, new.inode);
4115 old.inode->i_ino, old_file_type);
4133 static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
4134 struct inode *new_dir, struct dentry *new_dentry)
4140 .inode = d_inode(old_dentry),
4145 .inode = d_inode(new_dentry),
4171 * Check for inode number is _not_ due to possible IO errors.
4177 if (!old.bh || le32_to_cpu(old.de->inode) != old.inode->i_ino)
4189 if (!new.bh || le32_to_cpu(new.de->inode) != new.inode->i_ino)
4204 if (S_ISDIR(old.inode->i_mode)) {
4210 if (S_ISDIR(new.inode->i_mode)) {
4231 retval = ext4_setent(handle, &new, old.inode->i_ino, old.de->file_type);
4235 retval = ext4_setent(handle, &old, new.inode->i_ino, new_file_type);
4243 ctime = current_time(old.inode);
4244 old.inode->i_ctime = ctime;
4245 new.inode->i_ctime = ctime;
4246 retval = ext4_mark_inode_dirty(handle, old.inode);
4249 retval = ext4_mark_inode_dirty(handle, new.inode);
4252 ext4_fc_mark_ineligible(new.inode->i_sb,
4278 static int ext4_rename2(struct inode *old_dir, struct dentry *old_dentry,
4279 struct inode *new_dir, struct dentry *new_dentry,