From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50D15C433ED for ; Mon, 10 May 2021 09:30:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EC8A61466 for ; Mon, 10 May 2021 09:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230334AbhEJJbw (ORCPT ); Mon, 10 May 2021 05:31:52 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:2428 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230319AbhEJJbv (ORCPT ); Mon, 10 May 2021 05:31:51 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FdwhQ6XLkzCr8s; Mon, 10 May 2021 17:28:06 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Mon, 10 May 2021 17:30:35 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 3/3] f2fs: compress: fix to assign cc.cluster_idx correctly Date: Mon, 10 May 2021 17:30:32 +0800 Message-ID: <20210510093032.35466-3-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210510093032.35466-1-yuchao0@huawei.com> References: <20210510093032.35466-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; goto retry; } } -- 2.29.2