All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Fengnan Chang <changfengnan@vivo.com>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH v2 1/3] f2fs: intorduce f2fs_all_cluster_page_ready
Date: Mon, 11 Jul 2022 17:24:38 +0800	[thread overview]
Message-ID: <1d2c1281-58ab-5f73-d089-b221bbc5c03a@kernel.org> (raw)
In-Reply-To: <20220507081710.117162-2-changfengnan@vivo.com>

On 2022/5/7 16:17, Fengnan Chang wrote:
> When write total cluster, all pages is uptodate, there is not need to call
> f2fs_prepare_compress_overwrite, intorduce f2fs_all_cluster_page_ready
> to avoid this.
> 
> Signed-off-by: Fengnan Chang <changfengnan@vivo.com>
> ---
>   fs/f2fs/compress.c | 11 ++++++++---
>   fs/f2fs/data.c     |  9 +++++++--
>   fs/f2fs/f2fs.h     |  4 ++--
>   3 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index 12a56f9e1572..fd28844aa53f 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -871,20 +871,25 @@ bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index)
>   	return is_page_in_cluster(cc, index);
>   }
>   
> -bool f2fs_all_cluster_page_loaded(struct compress_ctx *cc, struct pagevec *pvec,
> -				int index, int nr_pages)
> +bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
> +				int index, int nr_pages, bool uptodate)
>   {
>   	unsigned long pgidx;
>   	int i;
>   
> +	if (uptodate && (pgidx % cc->cluster_size))
> +		return false;

How about adding comments here to describe the logic if @update is true.

> +
>   	if (nr_pages - index < cc->cluster_size)
>   		return false;
>   
>   	pgidx = pvec->pages[index]->index;
>   
> -	for (i = 1; i < cc->cluster_size; i++) {
> +	for (i = 0; i < cc->cluster_size; i++) {

@i should be assigned differently according to @update?

>   		if (pvec->pages[index + i]->index != pgidx + i)
>   			return false;
> +		if (uptodate && !PageUptodate(pvec->pages[index + i]))
> +			return false;
>   	}
>   
>   	return true;
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 9a1a526f2092..77af65838a7c 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -2967,6 +2967,11 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
>   				if (!f2fs_cluster_is_empty(&cc))
>   					goto lock_page;
>   
> +				if (f2fs_all_cluster_page_ready(&cc,
> +					&pvec, i, nr_pages, true)) {
> +					goto lock_page;
> +				}

./scripts/checkpatch.pl mentioned that:

braces {} are not necessary for single statement blocks

Thanks,

> +
>   				ret2 = f2fs_prepare_compress_overwrite(
>   							inode, &pagep,
>   							page->index, &fsdata);
> @@ -2977,8 +2982,8 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
>   				} else if (ret2 &&
>   					(!f2fs_compress_write_end(inode,
>   						fsdata, page->index, 1) ||
> -					 !f2fs_all_cluster_page_loaded(&cc,
> -						&pvec, i, nr_pages))) {
> +					 !f2fs_all_cluster_page_ready(&cc,
> +						&pvec, i, nr_pages, false))) {
>   					retry = 1;
>   					break;
>   				}
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 38cbed0f544e..5a33f2d4aee8 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -4177,8 +4177,8 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed,
>   							block_t blkaddr);
>   bool f2fs_cluster_is_empty(struct compress_ctx *cc);
>   bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index);
> -bool f2fs_all_cluster_page_loaded(struct compress_ctx *cc, struct pagevec *pvec,
> -				int index, int nr_pages);
> +bool f2fs_all_cluster_page_ready(struct compress_ctx *cc, struct pagevec *pvec,
> +				int index, int nr_pages, bool uptodate);
>   bool f2fs_sanity_check_cluster(struct dnode_of_data *dn);
>   void f2fs_compress_ctx_add_page(struct compress_ctx *cc, struct page *page);
>   int f2fs_write_multi_pages(struct compress_ctx *cc,


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

  reply	other threads:[~2022-07-11  9:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-07  8:17 [f2fs-dev] [PATCH v2 0/3] support compressed file write/read amplifiction Fengnan Chang via Linux-f2fs-devel
2022-05-07  8:17 ` [f2fs-dev] [PATCH v2 1/3] f2fs: intorduce f2fs_all_cluster_page_ready Fengnan Chang via Linux-f2fs-devel
2022-07-11  9:24   ` Chao Yu [this message]
2022-05-07  8:17 ` [f2fs-dev] [PATCH v2 2/3] f2fs: use onstack pages instead of pvec Fengnan Chang via Linux-f2fs-devel
2022-07-11  9:46   ` Chao Yu
2022-05-07  8:17 ` [f2fs-dev] [PATCH v2 3/3] f2fs: support compressed file write/read amplifiction Fengnan Chang via Linux-f2fs-devel
2022-07-10 12:40   ` fengnan chang
2022-07-11 10:10   ` Chao Yu
2022-06-03  2:13 ` [f2fs-dev] [PATCH v2 0/3] " fengnan chang

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=1d2c1281-58ab-5f73-d089-b221bbc5c03a@kernel.org \
    --to=chao@kernel.org \
    --cc=changfengnan@vivo.com \
    --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.