diff options
author | Jan Kara <jack@suse.cz> | 2016-03-10 04:54:00 +0100 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2016-03-10 04:54:00 +0100 |
commit | facab4d9711e7aa3532cb82643803e8f1b9518e8 (patch) | |
tree | 5c0f800db5aeb1fca6842c81cd3821ae847fcc0d /fs/ext4/indirect.c | |
parent | ext4: factor out determining of hole size (diff) | |
download | linux-facab4d9711e7aa3532cb82643803e8f1b9518e8.tar.xz linux-facab4d9711e7aa3532cb82643803e8f1b9518e8.zip |
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>
Diffstat (limited to 'fs/ext4/indirect.c')
-rw-r--r-- | fs/ext4/indirect.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c index 1655ff195e0e..3027fa681de5 100644 --- a/fs/ext4/indirect.c +++ b/fs/ext4/indirect.c @@ -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; /* |