Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21231253ybl; Mon, 6 Jan 2020 00:03:14 -0800 (PST) X-Google-Smtp-Source: APXvYqxeWuMpmTL3OBIaXt0fvtX8an3oLOgJOKmsLm9v51pg5IBxq9B+TGTreoLepjdJfs3lkgoH X-Received: by 2002:a9d:5885:: with SMTP id x5mr111850789otg.132.1578297794163; Mon, 06 Jan 2020 00:03:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578297794; cv=none; d=google.com; s=arc-20160816; b=pP84Bflil5HnwiCfxUmCUrcx2RJ3RCcfATUX49X+qnPlppLjDr0zZd58TJcHnR9hNg ma89GrVdFSyziH9gLaf/Nran5sYnKxlOy4sknAKymFBtwLECU2CD6iGKKZzEoOf18SKI IiIYKa1yDgbF9b5u+eUuSiHnMMkcnpv5nnOHQEWpldZNXdEhSp7E6wQwd++8PsuXlARH t2uQHMKDIDXaZypupWtbXCbwjjjSb5TXJv81hnO9y3kyGn4MVE9JjtT+1fOPOZG+gtmi dNQhwjexOBGQouqfzSxEmaJsTThLlAFx5gEV0AkTkc7q2upS2rROIBe7i3FBHPdBZTGP gLnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=q6KAFFeLAVwA5q3JuvwrGXxzHrh/utyWNPt/UXSiJAI=; b=jo+VM6ZLnRJOj3ugz94ziVqR4iQCUwbE/SQGQIzdEzaS/pA5bF/irWyeIQqu8p8Enc 2Xg0r9ZNeMJ0vYu45wnXJSuMADkIhypb0Vn2zjpQicxvXAolpJI2bTXQN+iHpmiIbxE8 T6rW+T+GmDKyNsc6/BflWsa4m9ucsYcLhlIscHgPLZ99v1c5AtyKK011SwGDXhV5lXjU hYPnnV9uSh04xLqCHz6e91MUXdYiVTB2LR8iN1IxVyofCx0+9UJLV5KY9eHfMp66Hy8Z RDbEDPDTiHDPfSbwUtnQUmI+Fn0q9gN6wRSFDLsSXjf+Sqb3zuQYPjpdhhQ5Qw+7OQrx qqHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m82si31805909oig.129.2020.01.06.00.03.01; Mon, 06 Jan 2020 00:03:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726427AbgAFICD (ORCPT + 99 others); Mon, 6 Jan 2020 03:02:03 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:42272 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726281AbgAFIB6 (ORCPT ); Mon, 6 Jan 2020 03:01:58 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id EA950C201F57EAF36E37; Mon, 6 Jan 2020 16:01:55 +0800 (CST) Received: from szvp000203569.huawei.com (10.120.216.130) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Mon, 6 Jan 2020 16:01:48 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite() Date: Mon, 6 Jan 2020 16:01:43 +0800 Message-ID: <20200106080144.52363-3-yuchao0@huawei.com> X-Mailer: git-send-email 2.18.0.rc1 In-Reply-To: <20200106080144.52363-1-yuchao0@huawei.com> References: <20200106080144.52363-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - fix to release cluster pages in retry flow - fix to call f2fs_put_dnode() & __do_map_lock() in error path Signed-off-by: Chao Yu --- fs/f2fs/compress.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index fc4510729654..3390351d2e39 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -626,20 +626,26 @@ static int prepare_compress_overwrite(struct compress_ctx *cc, } for (i = 0; i < cc->cluster_size; i++) { + f2fs_bug_on(sbi, cc->rpages[i]); + page = find_lock_page(mapping, start_idx + i); f2fs_bug_on(sbi, !page); f2fs_wait_on_page_writeback(page, DATA, true, true); - cc->rpages[i] = page; + f2fs_compress_ctx_add_page(cc, page); f2fs_put_page(page, 0); if (!PageUptodate(page)) { - for (idx = 0; idx < cc->cluster_size; idx++) { - f2fs_put_page(cc->rpages[idx], - (idx <= i) ? 1 : 0); + for (idx = 0; idx <= i; idx++) { + unlock_page(cc->rpages[idx]); cc->rpages[idx] = NULL; } + for (idx = 0; idx < cc->cluster_size; idx++) { + page = find_lock_page(mapping, start_idx + idx); + f2fs_put_page(page, 1); + f2fs_put_page(page, 0); + } kvfree(cc->rpages); cc->nr_rpages = 0; goto retry; @@ -654,16 +660,20 @@ static int prepare_compress_overwrite(struct compress_ctx *cc, for (i = cc->cluster_size - 1; i > 0; i--) { ret = f2fs_get_block(&dn, start_idx + i); if (ret) { - /* TODO: release preallocate blocks */ i = cc->cluster_size; - goto unlock_pages; + break; } if (dn.data_blkaddr != NEW_ADDR) break; } + f2fs_put_dnode(&dn); + __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false); + + if (ret) + goto unlock_pages; } *fsdata = cc->rpages; -- 2.18.0.rc1