Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21783661ybl; Mon, 6 Jan 2020 11:10:19 -0800 (PST) X-Google-Smtp-Source: APXvYqzMZrCSDVnHEL+TyqgBXIccDP2oL7sHh682bjUrlVJEezNb/KotP3MooRElIFnqLNMorkSp X-Received: by 2002:a05:6830:593:: with SMTP id c19mr8604794oth.81.1578337818687; Mon, 06 Jan 2020 11:10:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578337818; cv=none; d=google.com; s=arc-20160816; b=KpsIwIIVZkbg7HQyrvShziq6UOrAcjHYiiTmtrf7yNPRxvjxJ4KHJNr/Np9ifeF8y6 hfXVidmuiJvMJOXlMZqfvSnyTXYu8v21gI1f21+CAXgtEcdS4ph+Bfz7Qob1n3gEWmww sIyKDodmEsf50gwmkLiV80+/1h67rFH6nihtSwavWf6Fg1Ch8XVYatx+q1AGATIFIOQv AbDhd+vtaIApVkb5qnhsBLIdWffFcaOzWrxIkLN7/+AVRAIDw3anqbIOnlzSQwBKag19 nNybPWjYo4HYI4b6wGp0wgUMgYqYnEmkmuVJPH6STJvtFAlZNlDZjIkpBuzsqeyxz8lB scTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GwyBDE5RoEQJmaXwfGvUfzarH+tvNp/I7gtqeEGLJrA=; b=IgKL+oExUyVrc62vjwhNp6iG9xqF7D7GBfEPGII5XA6yeRTETBzePX9wrm1J7oO9b8 9q3oDTE3xN4lwKZesuya4M0GdQT4rIWsoByPFTW/vJFMWsQ03430RDKvrfI2Gh80Ao2H 0ebqG6lmdPq4OlJ0T4NIrVYYvEBSp3XOlTcO8WMmSCgB7IMovKNOd8Rg9N011DmW7xGa roSQqn5SZ3V0GvnYQ5ZpW33ZYpXU4MXYHPgM9kyVM2pP3xoR/a0VREB3bbzHRoGVZMwy VM9kue4Nc/Z+ml7Je/ct0nzUReV49iZ0gbSOuYml8r6hmUgBnUGghQf1pTCKtkjLxKQR YGCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jbPI6gd1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v11si28406943otr.158.2020.01.06.11.10.05; Mon, 06 Jan 2020 11:10:18 -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; dkim=pass header.i=@kernel.org header.s=default header.b=jbPI6gd1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbgAFTIK (ORCPT + 99 others); Mon, 6 Jan 2020 14:08:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:51586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726569AbgAFTIK (ORCPT ); Mon, 6 Jan 2020 14:08:10 -0500 Received: from localhost (unknown [104.132.0.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2549E2072E; Mon, 6 Jan 2020 19:08:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578337690; bh=GTgBx/JA91ia0+OMvTgPUGoIEEqGYFmp61UBCTw+K+g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jbPI6gd17MVlhjV1JDDBmHnf2an7DD5VWxs6DCFS9mIDC+HU5PAxeOfNzDqIIcHAp Q7+mf9RkCC/aJ0DNn8E7UYnoHWpmjsLmcCGq3ikfuSC6y/emkVTDsdsIH23IbT6J7i DCj8ab6ajH+5jyRGuttqhaYaNQjDMMsTd+WOQqWQ= Date: Mon, 6 Jan 2020 11:08:09 -0800 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org Subject: Re: [PATCH 3/4] f2fs: compress: fix error path in prepare_compress_overwrite() Message-ID: <20200106190809.GE50058@jaegeuk-macbookpro.roam.corp.google.com> References: <20200106080144.52363-1-yuchao0@huawei.com> <20200106080144.52363-3-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200106080144.52363-3-yuchao0@huawei.com> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/06, Chao Yu wrote: > - 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); Why do we need to lock the pages again? > + 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); We don't neeed this, since f2fs_reserve_block() put the dnode. > + > __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO, false); > + > + if (ret) > + goto unlock_pages; > } > > *fsdata = cc->rpages; > -- > 2.18.0.rc1