Skip to content

Commit a908258

Browse files
zhangyi089tytso
authored andcommitted
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 <[email protected]> Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 667de03 commit a908258

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

fs/ext4/extents.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,7 +3138,7 @@ static void ext4_zeroout_es(struct inode *inode, struct ext4_extent *ex)
31383138
return;
31393139

31403140
ext4_es_insert_extent(inode, ee_block, ee_len, ee_pblock,
3141-
EXTENT_STATUS_WRITTEN, 0);
3141+
EXTENT_STATUS_WRITTEN, false);
31423142
}
31433143

31443144
/* FIXME!! we need to try to merge to left or right after zero-out */
@@ -4158,7 +4158,7 @@ static ext4_lblk_t ext4_ext_determine_insert_hole(struct inode *inode,
41584158
/* Put just found gap into cache to speed up subsequent requests */
41594159
ext_debug(inode, " -> %u:%u\n", hole_start, len);
41604160
ext4_es_insert_extent(inode, hole_start, len, ~0,
4161-
EXTENT_STATUS_HOLE, 0);
4161+
EXTENT_STATUS_HOLE, false);
41624162

41634163
/* Update hole_len to reflect hole size after lblk */
41644164
if (hole_start != lblk)

fs/ext4/extents_status.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes,
848848
*/
849849
void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
850850
ext4_lblk_t len, ext4_fsblk_t pblk,
851-
unsigned int status, int flags)
851+
unsigned int status, bool delalloc_reserve_used)
852852
{
853853
struct extent_status newes;
854854
ext4_lblk_t end = lblk + len - 1;
@@ -863,8 +863,8 @@ void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
863863
if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
864864
return;
865865

866-
es_debug("add [%u/%u) %llu %x %x to extent status tree of inode %lu\n",
867-
lblk, len, pblk, status, flags, inode->i_ino);
866+
es_debug("add [%u/%u) %llu %x %d to extent status tree of inode %lu\n",
867+
lblk, len, pblk, status, delalloc_reserve_used, inode->i_ino);
868868

869869
if (!len)
870870
return;
@@ -945,7 +945,7 @@ void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
945945
resv_used += pending;
946946
if (resv_used)
947947
ext4_da_update_reserve_space(inode, resv_used,
948-
flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE);
948+
delalloc_reserve_used);
949949

950950
if (err1 || err2 || err3 < 0)
951951
goto retry;

fs/ext4/extents_status.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ extern void ext4_es_init_tree(struct ext4_es_tree *tree);
135135

136136
extern void ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
137137
ext4_lblk_t len, ext4_fsblk_t pblk,
138-
unsigned int status, int flags);
138+
unsigned int status,
139+
bool delalloc_reserve_used);
139140
extern void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
140141
ext4_lblk_t len, ext4_fsblk_t pblk,
141142
unsigned int status);

fs/ext4/inode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ static int ext4_map_query_blocks(handle_t *handle, struct inode *inode,
483483
status = map->m_flags & EXT4_MAP_UNWRITTEN ?
484484
EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
485485
ext4_es_insert_extent(inode, map->m_lblk, map->m_len,
486-
map->m_pblk, status, 0);
486+
map->m_pblk, status, false);
487487
return retval;
488488
}
489489

@@ -563,8 +563,8 @@ static int ext4_map_create_blocks(handle_t *handle, struct inode *inode,
563563

564564
status = map->m_flags & EXT4_MAP_UNWRITTEN ?
565565
EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
566-
ext4_es_insert_extent(inode, map->m_lblk, map->m_len,
567-
map->m_pblk, status, flags);
566+
ext4_es_insert_extent(inode, map->m_lblk, map->m_len, map->m_pblk,
567+
status, flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE);
568568

569569
return retval;
570570
}

0 commit comments

Comments
 (0)