Skip to content

Commit 7acd1b3

Browse files
riteshharjanitytso
authored andcommitted
ext4: Add a WARN_ON_ONCE for querying LAST_IN_LEAF instead
We added the documentation in ext4_map_blocks() for usage of EXT4_GET_BLOCKS_QUERY_LAST_IN_LEAF flag. But It's better to add a WARN_ON_ONCE in case if anyone tries using this flag with CREATE to avoid a random issue later. Since depth can change with CREATE and it needs to be re-calculated before using it in there. Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Reviewed-by: Ojaswin Mujoo <ojaswin@linux.ibm.com> Link: https://patch.msgid.link/ee6e82a224c50b432df9ce1ce3333c50182d8473.1747677758.git.ritesh.list@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 618320d commit 7acd1b3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/ext4/extents.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4445,9 +4445,11 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
44454445
* need to re-calculate the depth as it might have changed due to block
44464446
* allocation.
44474447
*/
4448-
if (flags & EXT4_GET_BLOCKS_QUERY_LAST_IN_LEAF)
4448+
if (flags & EXT4_GET_BLOCKS_QUERY_LAST_IN_LEAF) {
4449+
WARN_ON_ONCE(flags & EXT4_GET_BLOCKS_CREATE);
44494450
if (!err && ex && (ex == EXT_LAST_EXTENT(path[depth].p_hdr)))
44504451
map->m_flags |= EXT4_MAP_QUERY_LAST_IN_LEAF;
4452+
}
44514453

44524454
ext4_free_ext_path(path);
44534455

0 commit comments

Comments
 (0)