Skip to content

Commit a25a4e1

Browse files
gnehzuiltytso
authored andcommitted
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: Zheng Liu <wenqing.lz@taobao.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz>
1 parent be40136 commit a25a4e1

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

‎fs/ext4/extents.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3659,6 +3659,7 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
36593659
ext4_set_io_unwritten_flag(inode, io);
36603660
else
36613661
ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);
3662+
map->m_flags |= EXT4_MAP_UNWRITTEN;
36623663
if (ext4_should_dioread_nolock(inode))
36633664
map->m_flags |= EXT4_MAP_UNINIT;
36643665
goto out;
@@ -3680,8 +3681,10 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
36803681
* repeat fallocate creation request
36813682
* we already have an unwritten extent
36823683
*/
3683-
if (flags & EXT4_GET_BLOCKS_UNINIT_EXT)
3684+
if (flags & EXT4_GET_BLOCKS_UNINIT_EXT) {
3685+
map->m_flags |= EXT4_MAP_UNWRITTEN;
36843686
goto map_out;
3687+
}
36853688

36863689
/* buffered READ or buffered write_begin() lookup */
36873690
if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) {
@@ -4111,6 +4114,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
41114114
/* Mark uninitialized */
41124115
if (flags & EXT4_GET_BLOCKS_UNINIT_EXT){
41134116
ext4_ext_mark_uninitialized(&newex);
4117+
map->m_flags |= EXT4_MAP_UNWRITTEN;
41144118
/*
41154119
* io_end structure was created for every IO write to an
41164120
* uninitialized extent. To avoid unnecessary conversion,

‎fs/ext4/inode.c‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,16 +559,10 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
559559
return retval;
560560

561561
/*
562-
* When we call get_blocks without the create flag, the
563-
* BH_Unwritten flag could have gotten set if the blocks
564-
* requested were part of a uninitialized extent. We need to
565-
* clear this flag now that we are committed to convert all or
566-
* part of the uninitialized extent to be an initialized
567-
* extent. This is because we need to avoid the combination
568-
* of BH_Unwritten and BH_Mapped flags being simultaneously
569-
* set on the buffer_head.
562+
* Here we clear m_flags because after allocating an new extent,
563+
* it will be set again.
570564
*/
571-
map->m_flags &= ~EXT4_MAP_UNWRITTEN;
565+
map->m_flags &= ~EXT4_MAP_FLAGS;
572566

573567
/*
574568
* New blocks allocate and/or writing to uninitialized extent

0 commit comments

Comments
 (0)