Commit a25a4e1a authored by Zheng Liu's avatar Zheng Liu Committed by Theodore Ts'o

ext4: let ext4_ext_map_blocks return EXT4_MAP_UNWRITTEN flag

This commit lets ext4_ext_map_blocks return EXT4_MAP_UNWRITTEN flag
because in later commit ext4_map_blocks needs to use this flag to
determine the extent status.
Signed-off-by: default avatarZheng Liu <wenqing.lz@taobao.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
parent be401363
...@@ -3659,6 +3659,7 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, ...@@ -3659,6 +3659,7 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
ext4_set_io_unwritten_flag(inode, io); ext4_set_io_unwritten_flag(inode, io);
else else
ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);
map->m_flags |= EXT4_MAP_UNWRITTEN;
if (ext4_should_dioread_nolock(inode)) if (ext4_should_dioread_nolock(inode))
map->m_flags |= EXT4_MAP_UNINIT; map->m_flags |= EXT4_MAP_UNINIT;
goto out; goto out;
...@@ -3680,8 +3681,10 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, ...@@ -3680,8 +3681,10 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
* repeat fallocate creation request * repeat fallocate creation request
* we already have an unwritten extent * we already have an unwritten extent
*/ */
if (flags & EXT4_GET_BLOCKS_UNINIT_EXT) if (flags & EXT4_GET_BLOCKS_UNINIT_EXT) {
map->m_flags |= EXT4_MAP_UNWRITTEN;
goto map_out; goto map_out;
}
/* buffered READ or buffered write_begin() lookup */ /* buffered READ or buffered write_begin() lookup */
if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
...@@ -4111,6 +4114,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, ...@@ -4111,6 +4114,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
/* Mark uninitialized */ /* Mark uninitialized */
if (flags & EXT4_GET_BLOCKS_UNINIT_EXT){ if (flags & EXT4_GET_BLOCKS_UNINIT_EXT){
ext4_ext_mark_uninitialized(&newex); ext4_ext_mark_uninitialized(&newex);
map->m_flags |= EXT4_MAP_UNWRITTEN;
/* /*
* io_end structure was created for every IO write to an * io_end structure was created for every IO write to an
* uninitialized extent. To avoid unnecessary conversion, * uninitialized extent. To avoid unnecessary conversion,
......
...@@ -559,16 +559,10 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, ...@@ -559,16 +559,10 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
return retval; return retval;
/* /*
* When we call get_blocks without the create flag, the * Here we clear m_flags because after allocating an new extent,
* BH_Unwritten flag could have gotten set if the blocks * it will be set again.
* requested were part of a uninitialized extent. We need to */
* clear this flag now that we are committed to convert all or map->m_flags &= ~EXT4_MAP_FLAGS;
* part of the uninitialized extent to be an initialized
* extent. This is because we need to avoid the combination
* of BH_Unwritten and BH_Mapped flags being simultaneously
* set on the buffer_head.
*/
map->m_flags &= ~EXT4_MAP_UNWRITTEN;
/* /*
* New blocks allocate and/or writing to uninitialized extent * New blocks allocate and/or writing to uninitialized extent
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment