[PATCHv3,1/6] ext4: Add IOMAP_F_MERGED for non-extent based mapping
diff mbox series

Message ID 25695b1a4bc3b5c3a2f513ecb612195aa7154975.1582702693.git.riteshh@linux.ibm.com
State New
Headers show
Series
  • ext4: bmap & fiemap conversion to use iomap
Related show

Commit Message

Ritesh Harjani Feb. 26, 2020, 9:57 a.m. UTC
IOMAP_F_MERGED needs to be set in case of non-extent based mapping.
This is needed in later patches for conversion of ext4_fiemap to use iomap.

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
---
 fs/ext4/inode.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jan Kara Feb. 26, 2020, 12:26 p.m. UTC | #1
On Wed 26-02-20 15:27:03, Ritesh Harjani wrote:
> IOMAP_F_MERGED needs to be set in case of non-extent based mapping.
> This is needed in later patches for conversion of ext4_fiemap to use iomap.
> 
> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
> ---
>  fs/ext4/inode.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index d035acab5b2a..3b4230cf0bc2 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3335,6 +3335,10 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
>  	iomap->offset = (u64) map->m_lblk << blkbits;
>  	iomap->length = (u64) map->m_len << blkbits;
>  
> +	if ((map->m_flags & (EXT4_MAP_UNWRITTEN | EXT4_MAP_MAPPED)) &&
> +		!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
   ^^ we indent the second line of condition either like:

	if ((map->m_flags & (EXT4_MAP_UNWRITTEN | EXT4_MAP_MAPPED)) &&
	    !ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))

or like:

	if ((map->m_flags & (EXT4_MAP_UNWRITTEN | EXT4_MAP_MAPPED)) &&
			!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))

But on at the same level as following code block because that's highly
confusing at times...

Also EXT4_MAP_UNWRITTEN is never set for indirect block mapped files (that
on disk format does not support unwritten extents).

								Honza

> +		iomap->flags |= IOMAP_F_MERGED;
> +
>  	/*
>  	 * Flags passed to ext4_map_blocks() for direct I/O writes can result
>  	 * in m_flags having both EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN bits
> -- 
> 2.21.0
>
Ritesh Harjani Feb. 26, 2020, 12:33 p.m. UTC | #2
On 2/26/20 5:56 PM, Jan Kara wrote:
> On Wed 26-02-20 15:27:03, Ritesh Harjani wrote:
>> IOMAP_F_MERGED needs to be set in case of non-extent based mapping.
>> This is needed in later patches for conversion of ext4_fiemap to use iomap.
>>
>> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
>> ---
>>   fs/ext4/inode.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
>> index d035acab5b2a..3b4230cf0bc2 100644
>> --- a/fs/ext4/inode.c
>> +++ b/fs/ext4/inode.c
>> @@ -3335,6 +3335,10 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
>>   	iomap->offset = (u64) map->m_lblk << blkbits;
>>   	iomap->length = (u64) map->m_len << blkbits;
>>   
>> +	if ((map->m_flags & (EXT4_MAP_UNWRITTEN | EXT4_MAP_MAPPED)) &&
>> +		!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
>     ^^ we indent the second line of condition either like:
> 
> 	if ((map->m_flags & (EXT4_MAP_UNWRITTEN | EXT4_MAP_MAPPED)) &&
> 	    !ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))

Yes, I too prefer it this way. Will fix it.

> 
> or like:
> 
> 	if ((map->m_flags & (EXT4_MAP_UNWRITTEN | EXT4_MAP_MAPPED)) &&
> 			!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
> 
> But on at the same level as following code block because that's highly
> confusing at times...
> 
> Also EXT4_MAP_UNWRITTEN is never set for indirect block mapped files (that
> on disk format does not support unwritten extents).

Aah yes. Let me fix it.

> 
> 								Honza
> 
>> +		iomap->flags |= IOMAP_F_MERGED;
>> +
>>   	/*
>>   	 * Flags passed to ext4_map_blocks() for direct I/O writes can result
>>   	 * in m_flags having both EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN bits
>> -- 
>> 2.21.0
>>

Patch
diff mbox series

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index d035acab5b2a..3b4230cf0bc2 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3335,6 +3335,10 @@  static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
 	iomap->offset = (u64) map->m_lblk << blkbits;
 	iomap->length = (u64) map->m_len << blkbits;
 
+	if ((map->m_flags & (EXT4_MAP_UNWRITTEN | EXT4_MAP_MAPPED)) &&
+		!ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
+		iomap->flags |= IOMAP_F_MERGED;
+
 	/*
 	 * Flags passed to ext4_map_blocks() for direct I/O writes can result
 	 * in m_flags having both EXT4_MAP_MAPPED and EXT4_MAP_UNWRITTEN bits