diff options
author | Jan Kara <jack@suse.cz> | 2016-03-09 22:54:00 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2016-03-09 22:54:00 -0500 |
commit | facab4d9711e7aa3532cb82643803e8f1b9518e8 (patch) | |
tree | 5c0f800db5aeb1fca6842c81cd3821ae847fcc0d /fs/ext4/extents.c | |
parent | 140a52508a68387e22486659ff9eaa89a24f6e40 (diff) |
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/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 7858fc1d2501..2730039d4742 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -4374,13 +4374,20 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
4374 | if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { | 4374 | if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { |
4375 | ext4_lblk_t hole_start, hole_len; | 4375 | ext4_lblk_t hole_start, hole_len; |
4376 | 4376 | ||
4377 | hole_start = map->m_lblk; | ||
4378 | hole_len = ext4_ext_determine_hole(inode, path, &hole_start); | ||
4377 | /* | 4379 | /* |
4378 | * put just found gap into cache to speed up | 4380 | * put just found gap into cache to speed up |
4379 | * subsequent requests | 4381 | * subsequent requests |
4380 | */ | 4382 | */ |
4381 | hole_start = map->m_lblk; | ||
4382 | hole_len = ext4_ext_determine_hole(inode, path, &hole_start); | ||
4383 | ext4_ext_put_gap_in_cache(inode, hole_start, hole_len); | 4383 | ext4_ext_put_gap_in_cache(inode, hole_start, hole_len); |
4384 | |||
4385 | /* Update hole_len to reflect hole size after map->m_lblk */ | ||
4386 | if (hole_start != map->m_lblk) | ||
4387 | hole_len -= map->m_lblk - hole_start; | ||
4388 | map->m_pblk = 0; | ||
4389 | map->m_len = min_t(unsigned int, map->m_len, hole_len); | ||
4390 | |||
4384 | goto out2; | 4391 | goto out2; |
4385 | } | 4392 | } |
4386 | 4393 | ||