All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] optimize IPU
@ 2017-04-21  9:56 Hou Pengyang
  2017-04-21  9:56 ` [PATCH 1/3] f2fs: reconstruct code to write a data page Hou Pengyang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hou Pengyang @ 2017-04-21  9:56 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel

For IPU, there is no need to read dnode, these three patches are to fix this
issue.

patch 1): Reconstruct code in do_write_data_page, code logic stays unchanged,
patch 2): Under high-probability IPU scenario, we check extent_tree first
patch 3): Unlock dnode before IPU

Hou Pengyang (3):
  f2fs: reconstruct code to write a data page
  f2fs: lookup extent cache first under IPU scenario
  f2fs: unlock dnode before IPU

 fs/f2fs/data.c | 94 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 72 insertions(+), 22 deletions(-)

-- 
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* [PATCH 1/3] f2fs: reconstruct code to write a data page
  2017-04-21  9:56 [PATCH 0/3] optimize IPU Hou Pengyang
@ 2017-04-21  9:56 ` Hou Pengyang
  2017-04-21  9:56 ` [PATCH 2/3] f2fs: lookup extent cache first under IPU scenario Hou Pengyang
  2017-04-21  9:56 ` [PATCH 3/3] f2fs: unlock dnode before IPU Hou Pengyang
  2 siblings, 0 replies; 6+ messages in thread
From: Hou Pengyang @ 2017-04-21  9:56 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel

This patch introduces two functions:

	1) f2fs_encrypt_page -- encrypt data page before submit_bio
	2) do_rewrite_data_page -- IPU rewrite

The two functions are extraced from do_write_data_page, logic in
do_write_data_page stays unchanged.

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
---
 fs/f2fs/data.c | 66 ++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 44 insertions(+), 22 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b8dcd1e..4ba11a6 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1302,26 +1302,11 @@ static int f2fs_read_data_pages(struct file *file,
 	return f2fs_mpage_readpages(mapping, pages, NULL, nr_pages);
 }
 
-int do_write_data_page(struct f2fs_io_info *fio)
+static int f2fs_encrypt_page(struct f2fs_io_info *fio, struct page *page)
 {
-	struct page *page = fio->page;
 	struct inode *inode = page->mapping->host;
-	struct dnode_of_data dn;
 	int err = 0;
 
-	set_new_dnode(&dn, inode, NULL, NULL, 0);
-	err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
-	if (err)
-		return err;
-
-	fio->old_blkaddr = dn.data_blkaddr;
-
-	/* This page is already truncated */
-	if (fio->old_blkaddr == NULL_ADDR) {
-		ClearPageUptodate(page);
-		goto out_writepage;
-	}
-
 	if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode)) {
 		gfp_t gfp_flags = GFP_NOFS;
 
@@ -1343,9 +1328,50 @@ int do_write_data_page(struct f2fs_io_info *fio)
 				err = 0;
 				goto retry_encrypt;
 			}
-			goto out_writepage;
+			return err;
 		}
 	}
+	return err;
+}
+
+static int do_rewrite_data_page(struct f2fs_io_info *fio, struct page *page)
+{
+	struct inode *inode = page->mapping->host;
+	int err;
+
+	f2fs_bug_on(F2FS_P_SB(page), !fio->cp_rwsem_locked);
+
+	f2fs_unlock_op(F2FS_I_SB(inode));
+	fio->cp_rwsem_locked = false;
+	err = rewrite_data_page(fio);
+	set_inode_flag(inode, FI_UPDATE_WRITE);
+	trace_f2fs_do_write_data_page(page, IPU);
+	return err;
+
+}
+
+int do_write_data_page(struct f2fs_io_info *fio)
+{
+	struct page *page = fio->page;
+	struct inode *inode = page->mapping->host;
+	struct dnode_of_data dn;
+	int err = 0;
+
+	set_new_dnode(&dn, inode, NULL, NULL, 0);
+	err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
+	if (err)
+		return err;
+
+	fio->old_blkaddr = dn.data_blkaddr;
+
+	/* This page is already truncated */
+	if (fio->old_blkaddr == NULL_ADDR) {
+		ClearPageUptodate(page);
+		goto out_writepage;
+	}
+
+	if (f2fs_encrypt_page(fio, page))
+		goto out_writepage;
 
 	set_page_writeback(page);
 
@@ -1357,11 +1383,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
 			!is_cold_data(page) &&
 			!IS_ATOMIC_WRITTEN_PAGE(page) &&
 			need_inplace_update(inode, fio))) {
-		f2fs_unlock_op(F2FS_I_SB(inode));
-		fio->cp_rwsem_locked = false;
-		err = rewrite_data_page(fio);
-		set_inode_flag(inode, FI_UPDATE_WRITE);
-		trace_f2fs_do_write_data_page(page, IPU);
+		err = do_rewrite_data_page(fio, page);
 	} else {
 		write_data_page(&dn, fio);
 		trace_f2fs_do_write_data_page(page, OPU);
-- 
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* [PATCH 2/3] f2fs: lookup extent cache first under IPU scenario
  2017-04-21  9:56 [PATCH 0/3] optimize IPU Hou Pengyang
  2017-04-21  9:56 ` [PATCH 1/3] f2fs: reconstruct code to write a data page Hou Pengyang
@ 2017-04-21  9:56 ` Hou Pengyang
  2017-04-24  9:51   ` heyunlei
  2017-04-21  9:56 ` [PATCH 3/3] f2fs: unlock dnode before IPU Hou Pengyang
  2 siblings, 1 reply; 6+ messages in thread
From: Hou Pengyang @ 2017-04-21  9:56 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel

If a page is cold, NOT atomit written and need_ipu now, there is
a high probability that IPU should be adapted. For IPU, we try to
check extent tree to get the block index first, instead of reading
the dnode page, where may lead to an useless dnode IO, since no need to
update the dnode index for IPU.

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
---
 fs/f2fs/data.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 4ba11a6..3a660f7 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1355,8 +1355,34 @@ int do_write_data_page(struct f2fs_io_info *fio)
 	struct page *page = fio->page;
 	struct inode *inode = page->mapping->host;
 	struct dnode_of_data dn;
+	struct extent_info ei = {0,0,0};
 	int err = 0;
 
+	/*
+	 * If a page is cold, NOT atomit written and need_ipu now, there is
+	 * a high probability that IPU should be adapted. For IPU, we try to
+	 * check extent tree to get the block index first, instead of reading
+	 * the dnode page, where may lead to an useless dnode IO, since no need to
+	 * update the dnode index for IPU.
+	 */
+	if (unlikely(!is_cold_data(page) &&
+			!IS_ATOMIC_WRITTEN_PAGE(page) &&
+			need_inplace_update(inode, fio) &&
+			f2fs_lookup_extent_cache(inode, page->index, &ei))) {
+
+		fio->old_blkaddr = ei.blk + page->index - ei.fofs;
+
+		if (fio->old_blkaddr != NEW_ADDR &&
+				fio->old_blkaddr != NULL_ADDR) {
+			err = f2fs_encrypt_page(fio, page);
+			if (err)
+				return err;
+			set_page_writeback(page);
+			err = do_rewrite_data_page(fio, page);
+			return err;
+		}
+	}
+
 	set_new_dnode(&dn, inode, NULL, NULL, 0);
 	err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
 	if (err)
-- 
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* [PATCH 3/3] f2fs: unlock dnode before IPU
  2017-04-21  9:56 [PATCH 0/3] optimize IPU Hou Pengyang
  2017-04-21  9:56 ` [PATCH 1/3] f2fs: reconstruct code to write a data page Hou Pengyang
  2017-04-21  9:56 ` [PATCH 2/3] f2fs: lookup extent cache first under IPU scenario Hou Pengyang
@ 2017-04-21  9:56 ` Hou Pengyang
  2 siblings, 0 replies; 6+ messages in thread
From: Hou Pengyang @ 2017-04-21  9:56 UTC (permalink / raw)
  To: jaegeuk, chao; +Cc: linux-f2fs-devel

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
---
 fs/f2fs/data.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 3a660f7..fcd907c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1409,7 +1409,9 @@ int do_write_data_page(struct f2fs_io_info *fio)
 			!is_cold_data(page) &&
 			!IS_ATOMIC_WRITTEN_PAGE(page) &&
 			need_inplace_update(inode, fio))) {
+		f2fs_put_dnode(&dn);
 		err = do_rewrite_data_page(fio, page);
+		return err;
 	} else {
 		write_data_page(&dn, fio);
 		trace_f2fs_do_write_data_page(page, OPU);
-- 
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

* Re: [PATCH 2/3] f2fs: lookup extent cache first under IPU scenario
  2017-04-21  9:56 ` [PATCH 2/3] f2fs: lookup extent cache first under IPU scenario Hou Pengyang
@ 2017-04-24  9:51   ` heyunlei
  0 siblings, 0 replies; 6+ messages in thread
From: heyunlei @ 2017-04-24  9:51 UTC (permalink / raw)
  To: Hou Pengyang, jaegeuk, chao; +Cc: linux-f2fs-devel

Hi all,

Could we move IPU judgement outside cp_rwsem lock like below:

if (set ipu policy)
      if (ipu success)
		return
lock_op
      opu
unlock_op

And at same time when we write new checkpoint, we set ipu policy
during whole cp, the process is like this:

....|----OPU----|----IPU(write cp)----|----OPU----|----IPU(write cp)----|....

Thanks.

On 2017/4/21 17:56, Hou Pengyang wrote:
> If a page is cold, NOT atomit written and need_ipu now, there is
> a high probability that IPU should be adapted. For IPU, we try to
> check extent tree to get the block index first, instead of reading
> the dnode page, where may lead to an useless dnode IO, since no need to
> update the dnode index for IPU.
>
> Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
> ---
>  fs/f2fs/data.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 4ba11a6..3a660f7 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1355,8 +1355,34 @@ int do_write_data_page(struct f2fs_io_info *fio)
>  	struct page *page = fio->page;
>  	struct inode *inode = page->mapping->host;
>  	struct dnode_of_data dn;
> +	struct extent_info ei = {0,0,0};
>  	int err = 0;
>
> +	/*
> +	 * If a page is cold, NOT atomit written and need_ipu now, there is
> +	 * a high probability that IPU should be adapted. For IPU, we try to
> +	 * check extent tree to get the block index first, instead of reading
> +	 * the dnode page, where may lead to an useless dnode IO, since no need to
> +	 * update the dnode index for IPU.
> +	 */
> +	if (unlikely(!is_cold_data(page) &&
> +			!IS_ATOMIC_WRITTEN_PAGE(page) &&
> +			need_inplace_update(inode, fio) &&
> +			f2fs_lookup_extent_cache(inode, page->index, &ei))) {
> +
> +		fio->old_blkaddr = ei.blk + page->index - ei.fofs;
> +
> +		if (fio->old_blkaddr != NEW_ADDR &&
> +				fio->old_blkaddr != NULL_ADDR) {
> +			err = f2fs_encrypt_page(fio, page);
> +			if (err)
> +				return err;
> +			set_page_writeback(page);
> +			err = do_rewrite_data_page(fio, page);
> +			return err;
> +		}
> +	}
> +
>  	set_new_dnode(&dn, inode, NULL, NULL, 0);
>  	err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
>  	if (err)
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
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] 6+ messages in thread

* [PATCH 2/3] f2fs: lookup extent cache first under IPU scenario
  2017-04-22  9:22 [PATCH 0/3] optimize f2fs IPU v2 Hou Pengyang
@ 2017-04-22  9:22 ` Hou Pengyang
  0 siblings, 0 replies; 6+ messages in thread
From: Hou Pengyang @ 2017-04-22  9:22 UTC (permalink / raw)
  To: jaegeuk, chao, yuchao0; +Cc: linux-f2fs-devel

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/data.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6b18750..1c99ae1 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1367,8 +1367,32 @@ int do_write_data_page(struct f2fs_io_info *fio)
 	struct page *page = fio->page;
 	struct inode *inode = page->mapping->host;
 	struct dnode_of_data dn;
+	struct extent_info ei = {0,0,0};
 	int err = 0;
 
+	/*
+	 * If a page is cold, NOT atomit written and need_ipu now, there is
+	 * a high probability that IPU should be adapted. For IPU, we try to
+	 * check extent tree to get the block index first, instead of reading
+	 * the dnode page, where may lead to an useless dnode IO, since no need to
+	 * update the dnode index for IPU.
+	 */
+	if (unlikely(need_inplace_update_block(fio, page) &&
+			f2fs_lookup_extent_cache(inode, page->index, &ei))) {
+
+		fio->old_blkaddr = ei.blk + page->index - ei.fofs;
+
+		if (fio->old_blkaddr != NEW_ADDR &&
+				fio->old_blkaddr != NULL_ADDR) {
+			err = f2fs_encrypt_page(fio, page);
+			if (err)
+				return err;
+			set_page_writeback(page);
+			err = do_rewrite_data_page(fio, page);
+			return err;
+		}
+	}
+
 	set_new_dnode(&dn, inode, NULL, NULL, 0);
 	err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
 	if (err)
-- 
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

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

end of thread, other threads:[~2017-04-24  9:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21  9:56 [PATCH 0/3] optimize IPU Hou Pengyang
2017-04-21  9:56 ` [PATCH 1/3] f2fs: reconstruct code to write a data page Hou Pengyang
2017-04-21  9:56 ` [PATCH 2/3] f2fs: lookup extent cache first under IPU scenario Hou Pengyang
2017-04-24  9:51   ` heyunlei
2017-04-21  9:56 ` [PATCH 3/3] f2fs: unlock dnode before IPU Hou Pengyang
2017-04-22  9:22 [PATCH 0/3] optimize f2fs IPU v2 Hou Pengyang
2017-04-22  9:22 ` [PATCH 2/3] f2fs: lookup extent cache first under IPU scenario Hou Pengyang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.