LKML Archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Jaegeuk Kim <jaegeuk@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 2/3] f2fs: clear writeback when compression failed
Date: Thu, 11 Apr 2024 17:05:10 +0800	[thread overview]
Message-ID: <59414941-a15f-4eb0-8574-3b2a27d8ae69@kernel.org> (raw)
In-Reply-To: <20240409203411.1885121-2-jaegeuk@kernel.org>

On 2024/4/10 4:34, Jaegeuk Kim wrote:
> Let's stop issuing compressed writes and clear their writeback flags.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>   fs/f2fs/compress.c | 33 +++++++++++++++++++++++++++++++--
>   1 file changed, 31 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index d67c471ab5df..3a8ecc6aee84 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -1031,6 +1031,25 @@ static void set_cluster_writeback(struct compress_ctx *cc)
>   	}
>   }
>   
> +static void cancel_cluster_writeback(struct compress_ctx *cc, int submitted)
> +{
> +	int i;
> +
> +	for (i = 0; i < cc->cluster_size; i++) {
> +		if (!cc->rpages[i])
> +			continue;
> +		if (i < submitted) {
> +			if (i)
> +				f2fs_wait_on_page_writeback(cc->rpages[i],
> +						DATA, true, true);
> +			inode_inc_dirty_pages(cc->inode);
> +			lock_page(cc->rpages[i]);
> +		}
> +		clear_page_private_gcing(cc->rpages[i]);
> +		end_page_writeback(cc->rpages[i]);
> +	}
> +}
> +
>   static void set_cluster_dirty(struct compress_ctx *cc)
>   {
>   	int i;
> @@ -1232,7 +1251,6 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
>   		.page = NULL,
>   		.encrypted_page = NULL,
>   		.compressed_page = NULL,
> -		.submitted = 0,
>   		.io_type = io_type,
>   		.io_wbc = wbc,
>   		.encrypted = fscrypt_inode_uses_fs_layer_crypto(cc->inode) ?
> @@ -1358,7 +1376,15 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
>   			fio.compressed_page = cc->cpages[i - 1];
>   
>   		cc->cpages[i - 1] = NULL;
> +		fio.submitted = 0;
>   		f2fs_outplace_write_data(&dn, &fio);
> +		if (unlikely(!fio.submitted)) {
> +			cancel_cluster_writeback(cc, i);
> +
> +			/* To call fscrypt_finalize_bounce_page */
> +			i = cc->valid_nr_cpages;

*submitted = 0; ?

Thanks,

> +			goto out_destroy_crypt;
> +		}
>   		(*submitted)++;
>   unlock_continue:
>   		inode_dec_dirty_pages(cc->inode);
> @@ -1392,8 +1418,11 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
>   out_destroy_crypt:
>   	page_array_free(cc->inode, cic->rpages, cc->cluster_size);
>   
> -	for (--i; i >= 0; i--)
> +	for (--i; i >= 0; i--) {
> +		if (!cc->cpages[i])
> +			continue;
>   		fscrypt_finalize_bounce_page(&cc->cpages[i]);
> +	}
>   out_put_cic:
>   	kmem_cache_free(cic_entry_slab, cic);
>   out_put_dnode:

  reply	other threads:[~2024-04-11  9:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 20:34 [PATCH 1/3] f2fs: use folio_test_writeback Jaegeuk Kim
2024-04-09 20:34 ` [PATCH 2/3] f2fs: clear writeback when compression failed Jaegeuk Kim
2024-04-11  9:05   ` Chao Yu [this message]
2024-04-12 20:57     ` [f2fs-dev] " Jaegeuk Kim
2024-04-16 16:49   ` [PATCH 2/3 v2] " Jaegeuk Kim
2024-04-23 19:47     ` [f2fs-dev] " Daeho Jeong
2024-04-25  2:15     ` Chao Yu
2024-04-09 20:34 ` [PATCH 3/3] f2fs: fix false alarm on invalid block address Jaegeuk Kim
2024-04-11  9:08   ` [f2fs-dev] " Chao Yu
2024-04-12 20:56     ` Jaegeuk Kim
2024-04-19 10:27       ` Juhyung Park
2024-04-19 17:50         ` Jaegeuk Kim
2024-04-25  7:29         ` Chao Yu
2024-04-28  1:23           ` Daeho Jeong
2024-04-28  9:08             ` Chao Yu
2024-04-11  8:56 ` [f2fs-dev] [PATCH 1/3] f2fs: use folio_test_writeback Chao Yu
2024-04-14 15:32 ` patchwork-bot+f2fs
2024-04-24 17:40 ` patchwork-bot+f2fs

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=59414941-a15f-4eb0-8574-3b2a27d8ae69@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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 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 read-only IMAP folder(s) and NNTP newsgroup(s).