All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Fengnan Chang <changfengnan@vivo.com>
To: jaegeuk@kernel.org, chao@kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Fengnan Chang <changfengnan@vivo.com>
Subject: [f2fs-dev] [PATCH v4] f2fs: compress: avoid unnecessary check in f2fs_prepare_compress_overwrite
Date: Fri,  7 May 2021 17:44:54 +0800	[thread overview]
Message-ID: <20210507094455.1695-1-changfengnan@vivo.com> (raw)

when write compressed file with O_TRUNC, there will be a lot of
unnecessary check valid blocks in f2fs_prepare_compress_overwrite,
especially when written in page size, remove it.

This patch will not bring significant performance improvements, I test
this on mobile phone, use androbench, the sequential write test case was
open file with O_TRUNC, set write size to 4KB,  performance improved
about 2%-3%. If write size set to 32MB, performance improved about 0.5%.

Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
---
 fs/f2fs/data.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index cf935474ffba..b9ec7b182f45 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3303,9 +3303,17 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 #ifdef CONFIG_F2FS_FS_COMPRESSION
 	if (f2fs_compressed_file(inode)) {
 		int ret;
+		pgoff_t end = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;

 		*fsdata = NULL;

+		/*
+		 * when write pos is bigger than inode size ,f2fs_prepare_compress_overwrite
+		 * always return 0, so check pos first to avoid this.
+		 */
+		if (index >= end)
+			goto repeat;
+
 		ret = f2fs_prepare_compress_overwrite(inode, pagep,
 							index, fsdata);
 		if (ret < 0) {
--
2.29.0



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

             reply	other threads:[~2021-05-07  9:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07  9:44 Fengnan Chang [this message]
2021-05-10 15:43 ` [f2fs-dev] [PATCH v4] f2fs: compress: avoid unnecessary check in f2fs_prepare_compress_overwrite Jaegeuk Kim
2021-05-11 11:10   ` [f2fs-dev] 答复: " changfengnan
2021-05-11 21:50     ` Jaegeuk Kim
2021-05-12  1:20       ` Gao Xiang
2021-05-12  1:52       ` Chao Yu
2021-05-13  1:41         ` [f2fs-dev] 答复: " changfengnan
2021-05-13 21:17         ` [f2fs-dev] " Eric Biggers
2021-05-14  1:15           ` Chao Yu
2021-05-17 21:18             ` Eric Biggers
2021-05-18  1:23               ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210507094455.1695-1-changfengnan@vivo.com \
    --to=changfengnan@vivo.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.