Commit 874eaba9 authored by Zhang Yi's avatar Zhang Yi Committed by Theodore Ts'o

ext4: make ext4_map_blocks() distinguish delalloc only extent

Add a new map flag EXT4_MAP_DELAYED to indicate the mapping range is a
delayed allocated only (not unwritten) one, and making
ext4_map_blocks() can distinguish it, no longer mixing it with holes.
Signed-off-by: default avatarZhang Yi <yi.zhang@huawei.com>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20240127015825.1608160-6-yi.zhang@huaweicloud.comSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 9f111822
...@@ -252,8 +252,10 @@ struct ext4_allocation_request { ...@@ -252,8 +252,10 @@ struct ext4_allocation_request {
#define EXT4_MAP_MAPPED BIT(BH_Mapped) #define EXT4_MAP_MAPPED BIT(BH_Mapped)
#define EXT4_MAP_UNWRITTEN BIT(BH_Unwritten) #define EXT4_MAP_UNWRITTEN BIT(BH_Unwritten)
#define EXT4_MAP_BOUNDARY BIT(BH_Boundary) #define EXT4_MAP_BOUNDARY BIT(BH_Boundary)
#define EXT4_MAP_DELAYED BIT(BH_Delay)
#define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\ #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\
EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY) EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\
EXT4_MAP_DELAYED)
struct ext4_map_blocks { struct ext4_map_blocks {
ext4_fsblk_t m_pblk; ext4_fsblk_t m_pblk;
......
...@@ -4076,8 +4076,11 @@ static ext4_lblk_t ext4_ext_determine_insert_hole(struct inode *inode, ...@@ -4076,8 +4076,11 @@ static ext4_lblk_t ext4_ext_determine_insert_hole(struct inode *inode,
/* /*
* The delalloc extent containing lblk, it must have been * The delalloc extent containing lblk, it must have been
* added after ext4_map_blocks() checked the extent status * added after ext4_map_blocks() checked the extent status
* tree, adjust the length to the delalloc extent's after * tree so we are not holding i_rwsem and delalloc info is
* lblk. * only stabilized by i_data_sem we are going to release
* soon. Don't modify the extent status tree and report
* extent as a hole, just adjust the length to the delalloc
* extent's after lblk.
*/ */
len = es.es_lblk + es.es_len - lblk; len = es.es_lblk + es.es_len - lblk;
return len; return len;
......
...@@ -515,6 +515,8 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode, ...@@ -515,6 +515,8 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
map->m_len = retval; map->m_len = retval;
} else if (ext4_es_is_delayed(&es) || ext4_es_is_hole(&es)) { } else if (ext4_es_is_delayed(&es) || ext4_es_is_hole(&es)) {
map->m_pblk = 0; map->m_pblk = 0;
map->m_flags |= ext4_es_is_delayed(&es) ?
EXT4_MAP_DELAYED : 0;
retval = es.es_len - (map->m_lblk - es.es_lblk); retval = es.es_len - (map->m_lblk - es.es_lblk);
if (retval > map->m_len) if (retval > map->m_len)
retval = map->m_len; retval = map->m_len;
......
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