linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs: assign write hint in direct write IO path
@ 2024-04-18  3:33 Chao Yu
  2024-04-19 17:53 ` Jaegeuk Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2024-04-18  3:33 UTC (permalink / raw)
  To: jaegeuk; +Cc: Hyunchul Lee, linux-kernel, linux-f2fs-devel

f2fs has its own write_hint policy, let's assign write hint for
direct write bio.

Cc: Hyunchul Lee <cheol.lee@lge.com>
Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/f2fs/f2fs.h    |  1 +
 fs/f2fs/file.c    | 15 ++++++++++++++-
 fs/f2fs/segment.c | 17 +++++++++++------
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index b3b878acc86b..3f7196122574 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3722,6 +3722,7 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
 			block_t old_addr, block_t new_addr,
 			unsigned char version, bool recover_curseg,
 			bool recover_newaddr);
+int f2fs_get_segment_temp(int seg_type);
 int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 			block_t old_blkaddr, block_t *new_blkaddr,
 			struct f2fs_summary *sum, int type,
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ac1ae85f3cc3..d382f8bc2fbe 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -4685,8 +4685,21 @@ static int f2fs_dio_write_end_io(struct kiocb *iocb, ssize_t size, int error,
 	return 0;
 }
 
+static void f2fs_dio_write_submit_io(const struct iomap_iter *iter,
+					struct bio *bio, loff_t file_offset)
+{
+	struct inode *inode = iter->inode;
+	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+	int seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint);
+	enum temp_type temp = f2fs_get_segment_temp(seg_type);
+
+	bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp);
+	submit_bio(bio);
+}
+
 static const struct iomap_dio_ops f2fs_iomap_dio_write_ops = {
-	.end_io = f2fs_dio_write_end_io,
+	.end_io		= f2fs_dio_write_end_io,
+	.submit_io	= f2fs_dio_write_submit_io,
 };
 
 static void f2fs_flush_buffered_write(struct address_space *mapping,
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index daa94669f7ee..2206199e8099 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3502,6 +3502,15 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
 	}
 }
 
+int f2fs_get_segment_temp(int seg_type)
+{
+	if (IS_HOT(seg_type))
+		return HOT;
+	else if (IS_WARM(seg_type))
+		return WARM;
+	return COLD;
+}
+
 static int __get_segment_type(struct f2fs_io_info *fio)
 {
 	int type = 0;
@@ -3520,12 +3529,8 @@ static int __get_segment_type(struct f2fs_io_info *fio)
 		f2fs_bug_on(fio->sbi, true);
 	}
 
-	if (IS_HOT(type))
-		fio->temp = HOT;
-	else if (IS_WARM(type))
-		fio->temp = WARM;
-	else
-		fio->temp = COLD;
+	fio->temp = f2fs_get_segment_temp(type);
+
 	return type;
 }
 
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: assign write hint in direct write IO path
  2024-04-18  3:33 [f2fs-dev] [PATCH] f2fs: assign write hint in direct write IO path Chao Yu
@ 2024-04-19 17:53 ` Jaegeuk Kim
  2024-04-20  2:29   ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2024-04-19 17:53 UTC (permalink / raw)
  To: Chao Yu; +Cc: Hyunchul Lee, linux-kernel, linux-f2fs-devel

Thanks, Chao,

If you don't mind, can I merge this into my patch. Ok?

On 04/18, Chao Yu wrote:
> f2fs has its own write_hint policy, let's assign write hint for
> direct write bio.
> 
> Cc: Hyunchul Lee <cheol.lee@lge.com>
> Signed-off-by: Chao Yu <chao@kernel.org>
> ---
>  fs/f2fs/f2fs.h    |  1 +
>  fs/f2fs/file.c    | 15 ++++++++++++++-
>  fs/f2fs/segment.c | 17 +++++++++++------
>  3 files changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index b3b878acc86b..3f7196122574 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3722,6 +3722,7 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
>  			block_t old_addr, block_t new_addr,
>  			unsigned char version, bool recover_curseg,
>  			bool recover_newaddr);
> +int f2fs_get_segment_temp(int seg_type);
>  int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
>  			block_t old_blkaddr, block_t *new_blkaddr,
>  			struct f2fs_summary *sum, int type,
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index ac1ae85f3cc3..d382f8bc2fbe 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -4685,8 +4685,21 @@ static int f2fs_dio_write_end_io(struct kiocb *iocb, ssize_t size, int error,
>  	return 0;
>  }
>  
> +static void f2fs_dio_write_submit_io(const struct iomap_iter *iter,
> +					struct bio *bio, loff_t file_offset)
> +{
> +	struct inode *inode = iter->inode;
> +	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> +	int seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint);
> +	enum temp_type temp = f2fs_get_segment_temp(seg_type);
> +
> +	bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp);
> +	submit_bio(bio);
> +}
> +
>  static const struct iomap_dio_ops f2fs_iomap_dio_write_ops = {
> -	.end_io = f2fs_dio_write_end_io,
> +	.end_io		= f2fs_dio_write_end_io,
> +	.submit_io	= f2fs_dio_write_submit_io,
>  };
>  
>  static void f2fs_flush_buffered_write(struct address_space *mapping,
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index daa94669f7ee..2206199e8099 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -3502,6 +3502,15 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
>  	}
>  }
>  
> +int f2fs_get_segment_temp(int seg_type)
> +{
> +	if (IS_HOT(seg_type))
> +		return HOT;
> +	else if (IS_WARM(seg_type))
> +		return WARM;
> +	return COLD;
> +}
> +
>  static int __get_segment_type(struct f2fs_io_info *fio)
>  {
>  	int type = 0;
> @@ -3520,12 +3529,8 @@ static int __get_segment_type(struct f2fs_io_info *fio)
>  		f2fs_bug_on(fio->sbi, true);
>  	}
>  
> -	if (IS_HOT(type))
> -		fio->temp = HOT;
> -	else if (IS_WARM(type))
> -		fio->temp = WARM;
> -	else
> -		fio->temp = COLD;
> +	fio->temp = f2fs_get_segment_temp(type);
> +
>  	return type;
>  }
>  
> -- 
> 2.40.1


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: assign write hint in direct write IO path
  2024-04-19 17:53 ` Jaegeuk Kim
@ 2024-04-20  2:29   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2024-04-20  2:29 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: Hyunchul Lee, linux-kernel, linux-f2fs-devel

On 2024/4/20 1:53, Jaegeuk Kim wrote:
> Thanks, Chao,
> 
> If you don't mind, can I merge this into my patch. Ok?

No problem. :)

Thanks,

> 
> On 04/18, Chao Yu wrote:
>> f2fs has its own write_hint policy, let's assign write hint for
>> direct write bio.
>>
>> Cc: Hyunchul Lee <cheol.lee@lge.com>
>> Signed-off-by: Chao Yu <chao@kernel.org>
>> ---
>>   fs/f2fs/f2fs.h    |  1 +
>>   fs/f2fs/file.c    | 15 ++++++++++++++-
>>   fs/f2fs/segment.c | 17 +++++++++++------
>>   3 files changed, 26 insertions(+), 7 deletions(-)
>>
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
>> index b3b878acc86b..3f7196122574 100644
>> --- a/fs/f2fs/f2fs.h
>> +++ b/fs/f2fs/f2fs.h
>> @@ -3722,6 +3722,7 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
>>   			block_t old_addr, block_t new_addr,
>>   			unsigned char version, bool recover_curseg,
>>   			bool recover_newaddr);
>> +int f2fs_get_segment_temp(int seg_type);
>>   int f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
>>   			block_t old_blkaddr, block_t *new_blkaddr,
>>   			struct f2fs_summary *sum, int type,
>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
>> index ac1ae85f3cc3..d382f8bc2fbe 100644
>> --- a/fs/f2fs/file.c
>> +++ b/fs/f2fs/file.c
>> @@ -4685,8 +4685,21 @@ static int f2fs_dio_write_end_io(struct kiocb *iocb, ssize_t size, int error,
>>   	return 0;
>>   }
>>   
>> +static void f2fs_dio_write_submit_io(const struct iomap_iter *iter,
>> +					struct bio *bio, loff_t file_offset)
>> +{
>> +	struct inode *inode = iter->inode;
>> +	struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
>> +	int seg_type = f2fs_rw_hint_to_seg_type(inode->i_write_hint);
>> +	enum temp_type temp = f2fs_get_segment_temp(seg_type);
>> +
>> +	bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, DATA, temp);
>> +	submit_bio(bio);
>> +}
>> +
>>   static const struct iomap_dio_ops f2fs_iomap_dio_write_ops = {
>> -	.end_io = f2fs_dio_write_end_io,
>> +	.end_io		= f2fs_dio_write_end_io,
>> +	.submit_io	= f2fs_dio_write_submit_io,
>>   };
>>   
>>   static void f2fs_flush_buffered_write(struct address_space *mapping,
>> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
>> index daa94669f7ee..2206199e8099 100644
>> --- a/fs/f2fs/segment.c
>> +++ b/fs/f2fs/segment.c
>> @@ -3502,6 +3502,15 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
>>   	}
>>   }
>>   
>> +int f2fs_get_segment_temp(int seg_type)
>> +{
>> +	if (IS_HOT(seg_type))
>> +		return HOT;
>> +	else if (IS_WARM(seg_type))
>> +		return WARM;
>> +	return COLD;
>> +}
>> +
>>   static int __get_segment_type(struct f2fs_io_info *fio)
>>   {
>>   	int type = 0;
>> @@ -3520,12 +3529,8 @@ static int __get_segment_type(struct f2fs_io_info *fio)
>>   		f2fs_bug_on(fio->sbi, true);
>>   	}
>>   
>> -	if (IS_HOT(type))
>> -		fio->temp = HOT;
>> -	else if (IS_WARM(type))
>> -		fio->temp = WARM;
>> -	else
>> -		fio->temp = COLD;
>> +	fio->temp = f2fs_get_segment_temp(type);
>> +
>>   	return type;
>>   }
>>   
>> -- 
>> 2.40.1


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-20  2:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-18  3:33 [f2fs-dev] [PATCH] f2fs: assign write hint in direct write IO path Chao Yu
2024-04-19 17:53 ` Jaegeuk Kim
2024-04-20  2:29   ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).