ext4: don't pass full mapping flags to ext4_es_insert_extent()

When converting a delalloc extent in ext4_es_insert_extent(), since we
only want to pass the info of whether the quota has already been claimed
if the allocation is a direct allocation from ext4_map_create_blocks(),
there is no need to pass full mapping flags, so changes to just pass
whether the EXT4_GET_BLOCKS_DELALLOC_RESERVE bit is set.

Suggested-by: Jan Kara <jack@suse.cz>
Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20240906061401.2980330-1-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Zhang Yi 2024-09-06 14:14:01 +08:00 committed by Theodore Ts'o
parent 667de03a3b
commit a90825898b
4 changed files with 11 additions and 10 deletions

View File

@ -3138,7 +3138,7 @@ static void ext4_zeroout_es(struct inode *inode, struct ext4_extent *ex)
return; return;
ext4_es_insert_extent(inode, ee_block, ee_len, ee_pblock, ext4_es_insert_extent(inode, ee_block, ee_len, ee_pblock,
EXTENT_STATUS_WRITTEN, 0); EXTENT_STATUS_WRITTEN, false);
} }
/* FIXME!! we need to try to merge to left or right after zero-out */ /* FIXME!! we need to try to merge to left or right after zero-out */
@ -4158,7 +4158,7 @@ insert_hole:
/* Put just found gap into cache to speed up subsequent requests */ /* Put just found gap into cache to speed up subsequent requests */
ext_debug(inode, " -> %u:%u\n", hole_start, len); ext_debug(inode, " -> %u:%u\n", hole_start, len);
ext4_es_insert_extent(inode, hole_start, len, ~0, ext4_es_insert_extent(inode, hole_start, len, ~0,
EXTENT_STATUS_HOLE, 0); EXTENT_STATUS_HOLE, false);
/* Update hole_len to reflect hole size after lblk */ /* Update hole_len to reflect hole size after lblk */
if (hole_start != lblk) if (hole_start != lblk)

View File

@ -848,7 +848,7 @@ out:
*/ */
void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
ext4_lblk_t len, ext4_fsblk_t pblk, ext4_lblk_t len, ext4_fsblk_t pblk,
unsigned int status, int flags) unsigned int status, bool delalloc_reserve_used)
{ {
struct extent_status newes; struct extent_status newes;
ext4_lblk_t end = lblk + len - 1; ext4_lblk_t end = lblk + len - 1;
@ -863,8 +863,8 @@ void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY) if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
return; return;
es_debug("add [%u/%u) %llu %x %x to extent status tree of inode %lu\n", es_debug("add [%u/%u) %llu %x %d to extent status tree of inode %lu\n",
lblk, len, pblk, status, flags, inode->i_ino); lblk, len, pblk, status, delalloc_reserve_used, inode->i_ino);
if (!len) if (!len)
return; return;
@ -945,7 +945,7 @@ error:
resv_used += pending; resv_used += pending;
if (resv_used) if (resv_used)
ext4_da_update_reserve_space(inode, resv_used, ext4_da_update_reserve_space(inode, resv_used,
flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE); delalloc_reserve_used);
if (err1 || err2 || err3 < 0) if (err1 || err2 || err3 < 0)
goto retry; goto retry;

View File

@ -135,7 +135,8 @@ extern void ext4_es_init_tree(struct ext4_es_tree *tree);
extern void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk, extern void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
ext4_lblk_t len, ext4_fsblk_t pblk, ext4_lblk_t len, ext4_fsblk_t pblk,
unsigned int status, int flags); unsigned int status,
bool delalloc_reserve_used);
extern void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk, extern void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
ext4_lblk_t len, ext4_fsblk_t pblk, ext4_lblk_t len, ext4_fsblk_t pblk,
unsigned int status); unsigned int status);

View File

@ -483,7 +483,7 @@ static int ext4_map_query_blocks(handle_t *handle, struct inode *inode,
status = map->m_flags & EXT4_MAP_UNWRITTEN ? status = map->m_flags & EXT4_MAP_UNWRITTEN ?
EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
ext4_es_insert_extent(inode, map->m_lblk, map->m_len, ext4_es_insert_extent(inode, map->m_lblk, map->m_len,
map->m_pblk, status, 0); map->m_pblk, status, false);
return retval; return retval;
} }
@ -563,8 +563,8 @@ static int ext4_map_create_blocks(handle_t *handle, struct inode *inode,
status = map->m_flags & EXT4_MAP_UNWRITTEN ? status = map->m_flags & EXT4_MAP_UNWRITTEN ?
EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN; EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
ext4_es_insert_extent(inode, map->m_lblk, map->m_len, ext4_es_insert_extent(inode, map->m_lblk, map->m_len, map->m_pblk,
map->m_pblk, status, flags); status, flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE);
return retval; return retval;
} }