From: Artem Blagodarenko Replace remaining uses of struct ext4_dir_entry in namei.c with struct ext4_dir_entry_2. The code paths affected by this change already depend on the filetype feature, so using struct ext4_dir_entry_2 is appropriate and avoids mixing the two directory entry types unnecessarily. This change does not affect support for 16-bit rec_len. Signed-off-by: Artem Blagodarenko --- fs/ext4/namei.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 4a47fbd8dd30..a316fc2ac41b 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -102,7 +102,7 @@ static struct buffer_head *ext4_append(handle_t *handle, } static int ext4_dx_csum_verify(struct inode *inode, - struct ext4_dir_entry *dirent); + struct ext4_dir_entry_2 *dirent); /* * Hints to ext4_read_dirblock regarding whether we expect a directory @@ -128,7 +128,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode, unsigned int line) { struct buffer_head *bh; - struct ext4_dir_entry *dirent; + struct ext4_dir_entry_2 *dirent; int is_dx_block = 0; if (block >= inode->i_size >> inode->i_blkbits) { @@ -160,7 +160,7 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode, } if (!bh) return NULL; - dirent = (struct ext4_dir_entry *) bh->b_data; + dirent = (struct ext4_dir_entry_2 *) bh->b_data; /* Determine whether or not we have an index block */ if (is_dx(inode)) { if (block == 0) @@ -317,13 +317,13 @@ static struct ext4_dir_entry_tail *get_dirent_tail(struct inode *inode, int blocksize = EXT4_BLOCK_SIZE(inode->i_sb); #ifdef PARANOID - struct ext4_dir_entry *d, *top; + struct ext4_dir_entry_2 *d, *top; - d = (struct ext4_dir_entry *)bh->b_data; - top = (struct ext4_dir_entry *)(bh->b_data + + d = (struct ext4_dir_entry_2 *)bh->b_data; + top = (struct ext4_dir_entry_2 *)(bh->b_data + (blocksize - sizeof(struct ext4_dir_entry_tail))); while (d < top && ext4_rec_len_from_disk(d->rec_len, blocksize)) - d = (struct ext4_dir_entry *)(((void *)d) + + d = (struct ext4_dir_entry_2 *)(((void *)d) + ext4_rec_len_from_disk(d->rec_len, blocksize)); if (d != top) @@ -410,10 +410,10 @@ int ext4_handle_dirty_dirblock(handle_t *handle, } static struct dx_countlimit *get_dx_countlimit(struct inode *inode, - struct ext4_dir_entry *dirent, + struct ext4_dir_entry_2 *dirent, int *offset) { - struct ext4_dir_entry *dp; + struct ext4_dir_entry_2 *de; struct dx_root_info *root; int count_offset; int blocksize = EXT4_BLOCK_SIZE(inode->i_sb); @@ -422,10 +422,10 @@ static struct dx_countlimit *get_dx_countlimit(struct inode *inode, if (rlen == blocksize) count_offset = 8; else if (rlen == 12) { - dp = (struct ext4_dir_entry *)(((void *)dirent) + 12); - if (ext4_rec_len_from_disk(dp->rec_len, blocksize) != blocksize - 12) + de = (struct ext4_dir_entry_2 *)(((void *)dirent) + 12); + if (ext4_rec_len_from_disk(de->rec_len, blocksize) != blocksize - 12) return NULL; - root = (struct dx_root_info *)(((void *)dp + 12)); + root = (struct dx_root_info *)(((void *)de + 12)); if (root->reserved_zero || root->info_length != sizeof(struct dx_root_info)) return NULL; @@ -438,7 +438,7 @@ static struct dx_countlimit *get_dx_countlimit(struct inode *inode, return (struct dx_countlimit *)(((void *)dirent) + count_offset); } -static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent, +static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry_2 *dirent, int count_offset, int count, struct dx_tail *t) { struct ext4_inode_info *ei = EXT4_I(inode); @@ -456,7 +456,7 @@ static __le32 ext4_dx_csum(struct inode *inode, struct ext4_dir_entry *dirent, } static int ext4_dx_csum_verify(struct inode *inode, - struct ext4_dir_entry *dirent) + struct ext4_dir_entry_2 *dirent) { struct dx_countlimit *c; struct dx_tail *t; @@ -485,7 +485,7 @@ static int ext4_dx_csum_verify(struct inode *inode, return 1; } -static void ext4_dx_csum_set(struct inode *inode, struct ext4_dir_entry *dirent) +static void ext4_dx_csum_set(struct inode *inode, struct ext4_dir_entry_2 *dirent) { struct dx_countlimit *c; struct dx_tail *t; @@ -515,7 +515,7 @@ static inline int ext4_handle_dirty_dx_node(handle_t *handle, struct inode *inode, struct buffer_head *bh) { - ext4_dx_csum_set(inode, (struct ext4_dir_entry *)bh->b_data); + ext4_dx_csum_set(inode, (struct ext4_dir_entry_2 *)bh->b_data); return ext4_handle_dirty_metadata(handle, inode, bh); } @@ -1488,7 +1488,7 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size, } static int is_dx_internal_node(struct inode *dir, ext4_lblk_t block, - struct ext4_dir_entry *de) + struct ext4_dir_entry_2 *de) { struct super_block *sb = dir->i_sb; @@ -1619,7 +1619,7 @@ static struct buffer_head *__ext4_find_entry(struct inode *dir, } if (!buffer_verified(bh) && !is_dx_internal_node(dir, block, - (struct ext4_dir_entry *)bh->b_data) && + (struct ext4_dir_entry_2 *)bh->b_data) && !ext4_dirblock_csum_verify(dir, bh)) { EXT4_ERROR_INODE_ERR(dir, EFSBADCRC, "checksumming directory " -- 2.43.7