linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: only flush the single temp bio cache which owns the target page
@ 2018-10-24  8:10 Yunlong Song
  2018-10-24  9:55 ` Chao Yu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yunlong Song @ 2018-10-24  8:10 UTC (permalink / raw)
  To: jaegeuk, chao, yuchao0, yunlong.song, yunlong.song
  Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
	linux-kernel

Previously, when f2fs finds which temp bio cache owns the target page,
it will flush all the three temp bio caches, but we only need to flush
one single bio cache indeed, which can help to keep bio merged.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 fs/f2fs/data.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 106f116..04ebbad 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -374,7 +374,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,
 
 static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode,
 						struct page *page, nid_t ino,
-						enum page_type type)
+						enum page_type type, enum temp_type *owner)
 {
 	enum page_type btype = PAGE_TYPE_OF_BIO(type);
 	enum temp_type temp;
@@ -392,6 +392,10 @@ static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode,
 		if (ret || btype == META)
 			break;
 	}
+	if (!ret || (!inode && !page && !ino))
+		*owner = NR_TEMP_TYPE;
+	else
+		*owner = temp;
 	return ret;
 }
 
@@ -421,9 +425,14 @@ static void __submit_merged_write_cond(struct f2fs_sb_info *sbi,
 {
 	enum temp_type temp;
 
-	if (!force && !has_merged_page(sbi, inode, page, ino, type))
+	if (!force && !has_merged_page(sbi, inode, page, ino, type, &temp))
 		return;
 
+	if (!force && temp != NR_TEMP_TYPE) {
+		__f2fs_submit_merged_write(sbi, type, temp);
+		return;
+	}
+
 	for (temp = HOT; temp < NR_TEMP_TYPE; temp++) {
 
 		__f2fs_submit_merged_write(sbi, type, temp);
-- 
1.8.5.2


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

* Re: [PATCH] f2fs: only flush the single temp bio cache which owns the target page
  2018-10-24  8:10 [PATCH] f2fs: only flush the single temp bio cache which owns the target page Yunlong Song
@ 2018-10-24  9:55 ` Chao Yu
  2018-10-24 11:35 ` [PATCH v2] " Yunlong Song
  2018-11-13  3:57 ` [PATCH v3] " Yunlong Song
  2 siblings, 0 replies; 7+ messages in thread
From: Chao Yu @ 2018-10-24  9:55 UTC (permalink / raw)
  To: Yunlong Song, jaegeuk, chao, yunlong.song
  Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
	linux-kernel

Hi Yunlong,

On 2018/10/24 16:10, Yunlong Song wrote:
> Previously, when f2fs finds which temp bio cache owns the target page,
> it will flush all the three temp bio caches, but we only need to flush
> one single bio cache indeed, which can help to keep bio merged.
> 
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
> ---
>  fs/f2fs/data.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 106f116..04ebbad 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -374,7 +374,7 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,
>  
>  static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode,
>  						struct page *page, nid_t ino,
> -						enum page_type type)
> +						enum page_type type, enum temp_type *owner)
>  {
>  	enum page_type btype = PAGE_TYPE_OF_BIO(type);
>  	enum temp_type temp;
> @@ -392,6 +392,10 @@ static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode,
>  		if (ret || btype == META)
>  			break;
>  	}
> +	if (!ret || (!inode && !page && !ino))
> +		*owner = NR_TEMP_TYPE;
> +	else
> +		*owner = temp;
>  	return ret;
>  }
>  
> @@ -421,9 +425,14 @@ static void __submit_merged_write_cond(struct f2fs_sb_info *sbi,
>  {
>  	enum temp_type temp;
>  
> -	if (!force && !has_merged_page(sbi, inode, page, ino, type))
> +	if (!force && !has_merged_page(sbi, inode, page, ino, type, &temp))
>  		return;
>  
> +	if (!force && temp != NR_TEMP_TYPE) {
> +		__f2fs_submit_merged_write(sbi, type, temp);

I think we need to add has_merged_page into __f2fs_submit_merged_write to
check whether we should submit bio from different log, otherwise we will
missed to submit bio in below condition:

- f2fs_write_cache_pages
 - add page into bio cache of cold log
 - add page into bio cache of warm log
 - f2fs_submit_merged_write_cond(inode)
   - __f2fs_submit_merged_write(warm) -- missed to submit bio of cold log

Thanks,

> +		return;
> +	}
> +
>  	for (temp = HOT; temp < NR_TEMP_TYPE; temp++) {
>  
>  		__f2fs_submit_merged_write(sbi, type, temp);
> 


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

* [PATCH v2] f2fs: only flush the single temp bio cache which owns the target page
  2018-10-24  8:10 [PATCH] f2fs: only flush the single temp bio cache which owns the target page Yunlong Song
  2018-10-24  9:55 ` Chao Yu
@ 2018-10-24 11:35 ` Yunlong Song
  2018-10-25  1:35   ` Chao Yu
  2018-11-13  0:15   ` Jaegeuk Kim
  2018-11-13  3:57 ` [PATCH v3] " Yunlong Song
  2 siblings, 2 replies; 7+ messages in thread
From: Yunlong Song @ 2018-10-24 11:35 UTC (permalink / raw)
  To: jaegeuk, chao, yuchao0, yunlong.song, yunlong.song
  Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
	linux-kernel

Previously, when f2fs finds which temp bio cache owns the target page,
it will flush all the three temp bio caches, but we only need to flush
one single bio cache indeed, which can help to keep bio merged.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 fs/f2fs/data.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 106f116..882e217 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -396,13 +396,17 @@ static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode,
 }
 
 static void __f2fs_submit_merged_write(struct f2fs_sb_info *sbi,
-				enum page_type type, enum temp_type temp)
+				struct inode *inode, struct page *page, nid_t ino,
+				enum page_type type, enum temp_type temp, bool force)
 {
 	enum page_type btype = PAGE_TYPE_OF_BIO(type);
 	struct f2fs_bio_info *io = sbi->write_io[btype] + temp;
 
 	down_write(&io->io_rwsem);
 
+	if (!force && !__has_merged_page(io, inode, page, ino))
+		goto out;
+
 	/* change META to META_FLUSH in the checkpoint procedure */
 	if (type >= META_FLUSH) {
 		io->fio.type = META_FLUSH;
@@ -412,6 +416,7 @@ static void __f2fs_submit_merged_write(struct f2fs_sb_info *sbi,
 			io->fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
 	}
 	__submit_merged_bio(io);
+out:
 	up_write(&io->io_rwsem);
 }
 
@@ -426,7 +431,7 @@ static void __submit_merged_write_cond(struct f2fs_sb_info *sbi,
 
 	for (temp = HOT; temp < NR_TEMP_TYPE; temp++) {
 
-		__f2fs_submit_merged_write(sbi, type, temp);
+		__f2fs_submit_merged_write(sbi, inode, page, ino, type, temp, force);
 
 		/* TODO: use HOT temp only for meta pages now. */
 		if (type >= META)
-- 
1.8.5.2


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

* Re: [PATCH v2] f2fs: only flush the single temp bio cache which owns the target page
  2018-10-24 11:35 ` [PATCH v2] " Yunlong Song
@ 2018-10-25  1:35   ` Chao Yu
  2018-11-13  0:15   ` Jaegeuk Kim
  1 sibling, 0 replies; 7+ messages in thread
From: Chao Yu @ 2018-10-25  1:35 UTC (permalink / raw)
  To: Yunlong Song, jaegeuk, chao, yunlong.song
  Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
	linux-kernel

On 2018/10/24 19:35, Yunlong Song wrote:
> Previously, when f2fs finds which temp bio cache owns the target page,
> it will flush all the three temp bio caches, but we only need to flush
> one single bio cache indeed, which can help to keep bio merged.
> 
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,


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

* Re: [PATCH v2] f2fs: only flush the single temp bio cache which owns the target page
  2018-10-24 11:35 ` [PATCH v2] " Yunlong Song
  2018-10-25  1:35   ` Chao Yu
@ 2018-11-13  0:15   ` Jaegeuk Kim
  1 sibling, 0 replies; 7+ messages in thread
From: Jaegeuk Kim @ 2018-11-13  0:15 UTC (permalink / raw)
  To: Yunlong Song
  Cc: chao, yuchao0, yunlong.song, miaoxie, bintian.wang, shengyong1,
	heyunlei, linux-f2fs-devel, linux-kernel

On 10/24, Yunlong Song wrote:
> Previously, when f2fs finds which temp bio cache owns the target page,
> it will flush all the three temp bio caches, but we only need to flush
> one single bio cache indeed, which can help to keep bio merged.
> 
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
> ---
>  fs/f2fs/data.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 106f116..882e217 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -396,13 +396,17 @@ static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode,
>  }
>  
>  static void __f2fs_submit_merged_write(struct f2fs_sb_info *sbi,
> -				enum page_type type, enum temp_type temp)
> +				struct inode *inode, struct page *page, nid_t ino,
> +				enum page_type type, enum temp_type temp, bool force)
>  {
>  	enum page_type btype = PAGE_TYPE_OF_BIO(type);
>  	struct f2fs_bio_info *io = sbi->write_io[btype] + temp;
>  
>  	down_write(&io->io_rwsem);
>  
> +	if (!force && !__has_merged_page(io, inode, page, ino))
> +		goto out;

Could you clean up this to call once in __submit_merged_write_cond() only?

> +
>  	/* change META to META_FLUSH in the checkpoint procedure */
>  	if (type >= META_FLUSH) {
>  		io->fio.type = META_FLUSH;
> @@ -412,6 +416,7 @@ static void __f2fs_submit_merged_write(struct f2fs_sb_info *sbi,
>  			io->fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
>  	}
>  	__submit_merged_bio(io);
> +out:
>  	up_write(&io->io_rwsem);
>  }
>  
> @@ -426,7 +431,7 @@ static void __submit_merged_write_cond(struct f2fs_sb_info *sbi,
>  
>  	for (temp = HOT; temp < NR_TEMP_TYPE; temp++) {
>  
> -		__f2fs_submit_merged_write(sbi, type, temp);
> +		__f2fs_submit_merged_write(sbi, inode, page, ino, type, temp, force);
>  
>  		/* TODO: use HOT temp only for meta pages now. */
>  		if (type >= META)
> -- 
> 1.8.5.2

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

* [PATCH v3] f2fs: only flush the single temp bio cache which owns the target page
  2018-10-24  8:10 [PATCH] f2fs: only flush the single temp bio cache which owns the target page Yunlong Song
  2018-10-24  9:55 ` Chao Yu
  2018-10-24 11:35 ` [PATCH v2] " Yunlong Song
@ 2018-11-13  3:57 ` Yunlong Song
  2018-11-14 10:49   ` Chao Yu
  2 siblings, 1 reply; 7+ messages in thread
From: Yunlong Song @ 2018-11-13  3:57 UTC (permalink / raw)
  To: jaegeuk, chao, yuchao0, yunlong.song, yunlong.song
  Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
	linux-kernel

Previously, when f2fs finds which temp bio cache owns the target page,
it will flush all the three temp bio caches, but we only need to flush
one single bio cache indeed, which can help to keep bio merged.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
---
 fs/f2fs/data.c | 37 ++++++++++---------------------------
 1 file changed, 10 insertions(+), 27 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6e0ffb1..cd8f670 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -372,29 +372,6 @@ static bool __has_merged_page(struct f2fs_bio_info *io, struct inode *inode,
 	return false;
 }
 
-static bool has_merged_page(struct f2fs_sb_info *sbi, struct inode *inode,
-						struct page *page, nid_t ino,
-						enum page_type type)
-{
-	enum page_type btype = PAGE_TYPE_OF_BIO(type);
-	enum temp_type temp;
-	struct f2fs_bio_info *io;
-	bool ret = false;
-
-	for (temp = HOT; temp < NR_TEMP_TYPE; temp++) {
-		io = sbi->write_io[btype] + temp;
-
-		down_read(&io->io_rwsem);
-		ret = __has_merged_page(io, inode, page, ino);
-		up_read(&io->io_rwsem);
-
-		/* TODO: use HOT temp only for meta pages now. */
-		if (ret || btype == META)
-			break;
-	}
-	return ret;
-}
-
 static void __f2fs_submit_merged_write(struct f2fs_sb_info *sbi,
 				enum page_type type, enum temp_type temp)
 {
@@ -420,13 +397,19 @@ static void __submit_merged_write_cond(struct f2fs_sb_info *sbi,
 				nid_t ino, enum page_type type, bool force)
 {
 	enum temp_type temp;
-
-	if (!force && !has_merged_page(sbi, inode, page, ino, type))
-		return;
+	bool ret = true;
 
 	for (temp = HOT; temp < NR_TEMP_TYPE; temp++) {
+		if (!force)	{
+			enum page_type btype = PAGE_TYPE_OF_BIO(type);
+			struct f2fs_bio_info *io = sbi->write_io[btype] + temp;
 
-		__f2fs_submit_merged_write(sbi, type, temp);
+			down_read(&io->io_rwsem);
+			ret = __has_merged_page(io, inode, page, ino);
+			up_read(&io->io_rwsem);
+		}
+		if (ret)
+			__f2fs_submit_merged_write(sbi, type, temp);
 
 		/* TODO: use HOT temp only for meta pages now. */
 		if (type >= META)
-- 
1.8.5.2


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

* Re: [PATCH v3] f2fs: only flush the single temp bio cache which owns the target page
  2018-11-13  3:57 ` [PATCH v3] " Yunlong Song
@ 2018-11-14 10:49   ` Chao Yu
  0 siblings, 0 replies; 7+ messages in thread
From: Chao Yu @ 2018-11-14 10:49 UTC (permalink / raw)
  To: Yunlong Song, jaegeuk, chao, yunlong.song
  Cc: miaoxie, bintian.wang, shengyong1, heyunlei, linux-f2fs-devel,
	linux-kernel

On 2018/11/13 11:57, Yunlong Song wrote:
> Previously, when f2fs finds which temp bio cache owns the target page,
> it will flush all the three temp bio caches, but we only need to flush
> one single bio cache indeed, which can help to keep bio merged.
> 
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,


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

end of thread, other threads:[~2018-11-14 10:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24  8:10 [PATCH] f2fs: only flush the single temp bio cache which owns the target page Yunlong Song
2018-10-24  9:55 ` Chao Yu
2018-10-24 11:35 ` [PATCH v2] " Yunlong Song
2018-10-25  1:35   ` Chao Yu
2018-11-13  0:15   ` Jaegeuk Kim
2018-11-13  3:57 ` [PATCH v3] " Yunlong Song
2018-11-14 10:49   ` 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).