@@ -152,10 +152,11 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
152
152
153
153
return bh ;
154
154
}
155
- if (!bh && (type == INDEX || type == DIRENT_HTREE )) {
155
+ /* The first directory block must not be a hole. */
156
+ if (!bh && (type == INDEX || type == DIRENT_HTREE || block == 0 )) {
156
157
ext4_error_inode (inode , func , line , block ,
157
- "Directory hole found for htree %s block" ,
158
- (type == INDEX ) ? "index" : "leaf" );
158
+ "Directory hole found for htree %s block %u " ,
159
+ (type == INDEX ) ? "index" : "leaf" , block );
159
160
return ERR_PTR (- EFSCORRUPTED );
160
161
}
161
162
if (!bh )
@@ -3131,10 +3132,7 @@ bool ext4_empty_dir(struct inode *inode)
3131
3132
EXT4_ERROR_INODE (inode , "invalid size" );
3132
3133
return false;
3133
3134
}
3134
- /* The first directory block must not be a hole,
3135
- * so treat it as DIRENT_HTREE
3136
- */
3137
- bh = ext4_read_dirblock (inode , 0 , DIRENT_HTREE );
3135
+ bh = ext4_read_dirblock (inode , 0 , EITHER );
3138
3136
if (IS_ERR (bh ))
3139
3137
return false;
3140
3138
@@ -3578,10 +3576,7 @@ static struct buffer_head *ext4_get_first_dir_block(handle_t *handle,
3578
3576
struct ext4_dir_entry_2 * de ;
3579
3577
unsigned int offset ;
3580
3578
3581
- /* The first directory block must not be a hole, so
3582
- * treat it as DIRENT_HTREE
3583
- */
3584
- bh = ext4_read_dirblock (inode , 0 , DIRENT_HTREE );
3579
+ bh = ext4_read_dirblock (inode , 0 , EITHER );
3585
3580
if (IS_ERR (bh )) {
3586
3581
* retval = PTR_ERR (bh );
3587
3582
return NULL ;
0 commit comments