aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/namei.c')
-rw-r--r--fs/ext4/namei.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 3825d6aa8336..6653fc35ecb7 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -416,15 +416,16 @@ static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent,
416{ 416{
417 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); 417 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
418 struct ext4_inode_info *ei = EXT4_I(inode); 418 struct ext4_inode_info *ei = EXT4_I(inode);
419 __u32 csum, old_csum; 419 __u32 csum;
420 __le32 save_csum;
420 int size; 421 int size;
421 422
422 size = count_offset + (count * sizeof(struct dx_entry)); 423 size = count_offset + (count * sizeof(struct dx_entry));
423 old_csum = t->dt_checksum; 424 save_csum = t->dt_checksum;
424 t->dt_checksum = 0; 425 t->dt_checksum = 0;
425 csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size); 426 csum = ext4_chksum(sbi, ei->i_csum_seed, (__u8 *)dirent, size);
426 csum = ext4_chksum(sbi, csum, (__u8 *)t, sizeof(struct dx_tail)); 427 csum = ext4_chksum(sbi, csum, (__u8 *)t, sizeof(struct dx_tail));
427 t->dt_checksum = old_csum; 428 t->dt_checksum = save_csum;
428 429
429 return cpu_to_le32(csum); 430 return cpu_to_le32(csum);
430} 431}
@@ -971,6 +972,17 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
971 hinfo.hash_version += 972 hinfo.hash_version +=
972 EXT4_SB(dir->i_sb)->s_hash_unsigned; 973 EXT4_SB(dir->i_sb)->s_hash_unsigned;
973 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed; 974 hinfo.seed = EXT4_SB(dir->i_sb)->s_hash_seed;
975 if (ext4_has_inline_data(dir)) {
976 int has_inline_data = 1;
977 count = htree_inlinedir_to_tree(dir_file, dir, 0,
978 &hinfo, start_hash,
979 start_minor_hash,
980 &has_inline_data);
981 if (has_inline_data) {
982 *next_hash = ~0;
983 return count;
984 }
985 }
974 count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo, 986 count = htree_dirblock_to_tree(dir_file, dir, 0, &hinfo,
975 start_hash, start_minor_hash); 987 start_hash, start_minor_hash);
976 *next_hash = ~0; 988 *next_hash = ~0;
@@ -1455,24 +1467,6 @@ struct dentry *ext4_get_parent(struct dentry *child)
1455 return d_obtain_alias(ext4_iget(child->d_inode->i_sb, ino)); 1467 return d_obtain_alias(ext4_iget(child->d_inode->i_sb, ino));
1456} 1468}
1457 1469
1458#define S_SHIFT 12
1459static unsigned char ext4_type_by_mode[S_IFMT >> S_SHIFT] = {
1460 [S_IFREG >> S_SHIFT] = EXT4_FT_REG_FILE,
1461 [S_IFDIR >> S_SHIFT] = EXT4_FT_DIR,
1462 [S_IFCHR >> S_SHIFT] = EXT4_FT_CHRDEV,
1463 [S_IFBLK >> S_SHIFT] = EXT4_FT_BLKDEV,
1464 [S_IFIFO >> S_SHIFT] = EXT4_FT_FIFO,
1465 [S_IFSOCK >> S_SHIFT] = EXT4_FT_SOCK,
1466 [S_IFLNK >> S_SHIFT] = EXT4_FT_SYMLINK,
1467};
1468
1469static inline void ext4_set_de_type(struct super_block *sb,
1470 struct ext4_dir_entry_2 *de,
1471 umode_t mode) {
1472 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FILETYPE))
1473 de->file_type = ext4_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
1474}
1475
1476/* 1470/*
1477 * Move count entries from end of map between two memory locations. 1471 * Move count entries from end of map between two memory locations.
1478 * Returns pointer to last entry moved. 1472 * Returns pointer to last entry moved.
@@ -2251,8 +2245,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
2251 dquot_initialize(dir); 2245 dquot_initialize(dir);
2252 2246
2253 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2247 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2254 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + 2248 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
2255 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
2256retry: 2249retry:
2257 inode = ext4_new_inode_start_handle(dir, mode, &dentry->d_name, 0, 2250 inode = ext4_new_inode_start_handle(dir, mode, &dentry->d_name, 0,
2258 NULL, EXT4_HT_DIR, credits); 2251 NULL, EXT4_HT_DIR, credits);
@@ -2286,8 +2279,7 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
2286 dquot_initialize(dir); 2279 dquot_initialize(dir);
2287 2280
2288 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2281 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2289 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + 2282 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
2290 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
2291retry: 2283retry:
2292 inode = ext4_new_inode_start_handle(dir, mode, &dentry->d_name, 0, 2284 inode = ext4_new_inode_start_handle(dir, mode, &dentry->d_name, 0,
2293 NULL, EXT4_HT_DIR, credits); 2285 NULL, EXT4_HT_DIR, credits);
@@ -2396,8 +2388,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
2396 dquot_initialize(dir); 2388 dquot_initialize(dir);
2397 2389
2398 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2390 credits = (EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2399 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + 2391 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3);
2400 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
2401retry: 2392retry:
2402 inode = ext4_new_inode_start_handle(dir, S_IFDIR | mode, 2393 inode = ext4_new_inode_start_handle(dir, S_IFDIR | mode,
2403 &dentry->d_name, 2394 &dentry->d_name,
@@ -2826,8 +2817,7 @@ static int ext4_symlink(struct inode *dir,
2826 * quota blocks, sb is already counted in previous macros). 2817 * quota blocks, sb is already counted in previous macros).
2827 */ 2818 */
2828 credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + 2819 credits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
2829 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + 2820 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3;
2830 EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb);
2831 } 2821 }
2832retry: 2822retry:
2833 inode = ext4_new_inode_start_handle(dir, S_IFLNK|S_IRWXUGO, 2823 inode = ext4_new_inode_start_handle(dir, S_IFLNK|S_IRWXUGO,