Re: [PATCH 3/3] f2fs: compress: fix to assign cc.cluster_idx correctly

From: Jaegeuk Kim
Date: Mon May 10 2021 - 12:09:58 EST


On 05/10, Chao Yu wrote:
> In f2fs_destroy_compress_ctx(), after f2fs_destroy_compress_ctx(),
> cc.cluster_idx will be cleared w/ NULL_CLUSTER, f2fs_cluster_blocks()
> may check wrong cluster metadata, fix it.
>
> Fixes: 4c8ff7095bef ("f2fs: support data compression")
> Signed-off-by: Chao Yu <yuchao0@xxxxxxxxxx>
> ---
> fs/f2fs/compress.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
> index 340815cd0887..30b003447510 100644
> --- a/fs/f2fs/compress.c
> +++ b/fs/f2fs/compress.c
> @@ -1066,6 +1066,8 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
> f2fs_put_rpages(cc);
> f2fs_unlock_rpages(cc, i + 1);
> f2fs_destroy_compress_ctx(cc);
> + cc->cluster_idx = index >>
> + F2FS_I(cc->inode)->i_log_cluster_size;

I didn't test tho, how about this?