Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1395736ybj; Thu, 7 May 2020 23:52:10 -0700 (PDT) X-Google-Smtp-Source: APiQypJuvO1oGDaDh6hNG93FmNhkCwKjGTVSNj0s5lLibTFG2aVejH4KkudnQENMDnmsUPrMkha8 X-Received: by 2002:a17:906:560b:: with SMTP id f11mr601849ejq.264.1588920730062; Thu, 07 May 2020 23:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588920730; cv=none; d=google.com; s=arc-20160816; b=NOriJ0UU7EVl0DaW4XbvmQYgIVIxBYQ3UqRrzAh02dEgNcGt427vonLbmsFIXH3iNu zFUJXmQhH/KDC+/5jwue21rr2UmeaihRtMCNoX/3bkCusbxNutnwbhm3+/gNbheUHeM1 2cm5sXHAFjyr2ywM6xazswthiGWBOLo2ppytv4yqszVQqWsbZRZbL+8V9eRI2N1/H+SK 3RsoqsLpTcxpRhpRfE9rynr6gZ/dzt5VZQjpbjvroW8wXQlj1vk0HPmWyNWV3H9c73wL 9f5kbtI4kCO4Yt2LkvEIuRlcC8YDMIMXQ5FOOhf1FuHC7UDHXlnpxxTTSw9rRL/4cLY3 JsuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=sHDUQknQzFwixPPH047L4akre8hnA1SW40ZGMygeZy8=; b=y6dapARgoycQ3IazXXXhlK3KS0HVvqir+V517N7Xu6Fc3l8MRnj6NDNrD7gc8e190j cDcQgUrwyX+7/ABCmOkX4EQn0GwJUrJNWS5WtvSrSAjyT8Tb8gMuTnkx2KXSjbdl8AaS +NYMgRQoEsP1n+QW32BqgXBGuVSFh+YWe868gtqDDLADQC5RESD5ZtpH6KzSGICEe4S7 C+uOcyqQrLOxEDd6L4R+UzaCuexZo0481VV4ncJpOTXQpCsf4er8tZ4fQtE+RDadCVPD DQCITRVUY49E1fVEDmp+yiUR3bF5HcH9721vE4MQu4FTWxl+FlRceMV2TKJq7CopAZhP WeAg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si436105edi.440.2020.05.07.23.51.44; Thu, 07 May 2020 23:52:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726048AbgEHGuV (ORCPT + 99 others); Fri, 8 May 2020 02:50:21 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33446 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725971AbgEHGuV (ORCPT ); Fri, 8 May 2020 02:50:21 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id D6EC0D4A70CC61C5C7D9; Fri, 8 May 2020 14:50:15 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.205) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 8 May 2020 14:50:11 +0800 Subject: Re: [f2fs-dev] [PATCH] f2fs: remove race condition in releasing cblocks To: Daeho Jeong , , , CC: Daeho Jeong References: <20200508042506.143395-1-daeho43@gmail.com> From: Chao Yu Message-ID: <4dfb73d9-03a0-bb2f-a112-1dd42db4d7bb@huawei.com> Date: Fri, 8 May 2020 14:50:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200508042506.143395-1-daeho43@gmail.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/5/8 12:25, Daeho Jeong wrote: > From: Daeho Jeong > > Now, if writing pages and releasing compress blocks occur > simultaneously, and releasing cblocks is executed more than one time > to a file, then total block count of filesystem and block count of the > file could be incorrect and damaged. > > We have to execute releasing compress blocks only one time for a file > without being interfered by writepages path. > > Signed-off-by: Daeho Jeong > --- > fs/f2fs/file.c | 31 ++++++++++++++++++++++++------- > 1 file changed, 24 insertions(+), 7 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 4aab4b42d8ba..a92bc51b9b28 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -3488,6 +3488,7 @@ static int f2fs_release_compress_blocks(struct file *filp, unsigned long arg) > pgoff_t page_idx = 0, last_idx; > unsigned int released_blocks = 0; > int ret; > + int writecount; > > if (!f2fs_sb_has_compression(F2FS_I_SB(inode))) > return -EOPNOTSUPP; Before inode_lock(), there is one case we may jump to out label, in this case, we may unlock inode incorrectly. if (!F2FS_I(inode)->i_compr_blocks) goto out; > - > - inode_unlock(inode); > out: > + inode_unlock(inode); > + > mnt_drop_write_file(filp); Thanks,