ext4: return hole from ext4_map_blocks()
Currently, ext4_map_blocks() just returns 0 when it finds a hole and allocation is not requested. However we have all the information available to tell how large the hole actually is and there are callers of ext4_map_blocks() which would save some block-by-block hole iteration if they knew this information. So fill in struct ext4_map_blocks even for holes with the information we have. We keep returning 0 for holes to maintain backward compatibility of the function. Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
@@ -555,8 +555,23 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,
|
||||
goto got_it;
|
||||
}
|
||||
|
||||
/* Next simple case - plain lookup or failed read of indirect block */
|
||||
if ((flags & EXT4_GET_BLOCKS_CREATE) == 0 || err == -EIO)
|
||||
/* Next simple case - plain lookup failed */
|
||||
if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
|
||||
unsigned epb = inode->i_sb->s_blocksize / sizeof(u32);
|
||||
int i;
|
||||
|
||||
/* Count number blocks in a subtree under 'partial' */
|
||||
count = 1;
|
||||
for (i = 0; partial + i != chain + depth - 1; i++)
|
||||
count *= epb;
|
||||
/* Fill in size of a hole we found */
|
||||
map->m_pblk = 0;
|
||||
map->m_len = min_t(unsigned int, map->m_len, count);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Failed read of indirect block */
|
||||
if (err == -EIO)
|
||||
goto cleanup;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user