Skip to content

Commit 874eaba

Browse files
zhangyi089tytso
authored andcommitted
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: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 9f11182 commit 874eaba

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

fs/ext4/ext4.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,10 @@ struct ext4_allocation_request {
252252
#define EXT4_MAP_MAPPED BIT(BH_Mapped)
253253
#define EXT4_MAP_UNWRITTEN BIT(BH_Unwritten)
254254
#define EXT4_MAP_BOUNDARY BIT(BH_Boundary)
255+
#define EXT4_MAP_DELAYED BIT(BH_Delay)
255256
#define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\
256-
EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY)
257+
EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\
258+
EXT4_MAP_DELAYED)
257259

258260
struct ext4_map_blocks {
259261
ext4_fsblk_t m_pblk;

fs/ext4/extents.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,8 +4076,11 @@ static ext4_lblk_t ext4_ext_determine_insert_hole(struct inode *inode,
40764076
/*
40774077
* The delalloc extent containing lblk, it must have been
40784078
* added after ext4_map_blocks() checked the extent status
4079-
* tree, adjust the length to the delalloc extent's after
4080-
* lblk.
4079+
* tree so we are not holding i_rwsem and delalloc info is
4080+
* only stabilized by i_data_sem we are going to release
4081+
* soon. Don't modify the extent status tree and report
4082+
* extent as a hole, just adjust the length to the delalloc
4083+
* extent's after lblk.
40814084
*/
40824085
len = es.es_lblk + es.es_len - lblk;
40834086
return len;

fs/ext4/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ int ext4_map_blocks(handle_t *handle, struct inode *inode,
515515
map->m_len = retval;
516516
} else if (ext4_es_is_delayed(&es) || ext4_es_is_hole(&es)) {
517517
map->m_pblk = 0;
518+
map->m_flags |= ext4_es_is_delayed(&es) ?
519+
EXT4_MAP_DELAYED : 0;
518520
retval = es.es_len - (map->m_lblk - es.es_lblk);
519521
if (retval > map->m_len)
520522
retval = map->m_len;

0 commit comments

Comments
 (0)