Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Zheng Liu and committed by
Theodore Ts'o
a25a4e1a be401363

+8 -10
+5 -1
fs/ext4/extents.c
··· 3659 3659 ext4_set_io_unwritten_flag(inode, io); 3660 3660 else 3661 3661 ext4_set_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN); 3662 + map->m_flags |= EXT4_MAP_UNWRITTEN; 3662 3663 if (ext4_should_dioread_nolock(inode)) 3663 3664 map->m_flags |= EXT4_MAP_UNINIT; 3664 3665 goto out; ··· 3681 3680 * repeat fallocate creation request 3682 3681 * we already have an unwritten extent 3683 3682 */ 3684 - if (flags & EXT4_GET_BLOCKS_UNINIT_EXT) 3683 + if (flags & EXT4_GET_BLOCKS_UNINIT_EXT) { 3684 + map->m_flags |= EXT4_MAP_UNWRITTEN; 3685 3685 goto map_out; 3686 + } 3686 3687 3687 3688 /* buffered READ or buffered write_begin() lookup */ 3688 3689 if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { ··· 4114 4111 /* Mark uninitialized */ 4115 4112 if (flags & EXT4_GET_BLOCKS_UNINIT_EXT){ 4116 4113 ext4_ext_mark_uninitialized(&newex); 4114 + map->m_flags |= EXT4_MAP_UNWRITTEN; 4117 4115 /* 4118 4116 * io_end structure was created for every IO write to an 4119 4117 * uninitialized extent. To avoid unnecessary conversion,
+3 -9
fs/ext4/inode.c
··· 559 559 return retval; 560 560 561 561 /* 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. 570 564 */ 571 - map->m_flags &= ~EXT4_MAP_UNWRITTEN; 565 + map->m_flags &= ~EXT4_MAP_FLAGS; 572 566 573 567 /* 574 568 * New blocks allocate and/or writing to uninitialized extent