Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp737160pxk; Thu, 24 Sep 2020 17:59:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWGEaFHs7DFKCE18Rwv7hJ2U4Dj8zXkU+7eeV11VW3ntcA35m3R/y91b26Dj49Gyb4ELPV X-Received: by 2002:aa7:da16:: with SMTP id r22mr1526392eds.132.1600995571602; Thu, 24 Sep 2020 17:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600995571; cv=none; d=google.com; s=arc-20160816; b=dxqmnoIcJ5eXdtPLKIZxkREUHYi0GSbXWBccC7f4Eufvk6CgwF2BQdPrvwPN2Ewgv6 QwJupE3NLQ7U5d0KSJP9Q1apdYLf14pyIwFQupw0H5GxCpBT2LEK2NkN/8WRFMUF40oN ROvc5/mr5P8uiJMa1sNgwLIQO1uFj9Wqmd03cyXqy2l6RHz8JK4o1vF49FHTyim6it42 KQQPGw1mpewB6BIXgZt9mDw/a2nVuxW4D70jK5JTt+RueUKHT4cS4nOhrG+5Arv4vfwx ifZZW93MNc3FbFa/uJTMxZv+8vMC1Ms5Lxm0CFbNMrt6d2ScbUWe4Yzj2PjCWIajrRbb W6yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=QW39vTESNQPLj4hy31Q2Y4xhwkFEJGaJvoSobd4Q7WM=; b=D0tjz50GRSvgrxx1j4vDaDrT/uy2Q0LU48Z/JRZHOoK5CJJC0psCKWF1oooKDr7be0 jmrZS1qur9qaQDZFateo7HiPjmW31ztja0zxid7NtRvW9I72wqLiWMx0xP3WX90U6w3C I1ZatgeOVBUFoDUykCRfffxWfONIXO6vUzrmDbdUy71UE+w48mt0F2QBmYaC4HogKtqe QVwtsPNrgI3KUixtJOGCk/yHvBFXSWrF7SyXQgAftGWkbPDglirfGWJkZ7DIQRqfp/Ev /+2p7f27oNyzVsRrOBTeF6f/k1JnTNgpaWXK4lo4v+DEc3gnmIkCRfT//jHWS+pqEWwP yNvQ== 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 b11si734501edq.546.2020.09.24.17.59.08; Thu, 24 Sep 2020 17:59:31 -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 S1726730AbgIYA5V (ORCPT + 99 others); Thu, 24 Sep 2020 20:57:21 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:45716 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726703AbgIYA5V (ORCPT ); Thu, 24 Sep 2020 20:57:21 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id DA3FBF253B9569A7D13D; Fri, 25 Sep 2020 08:57:18 +0800 (CST) Received: from [10.136.114.67] (10.136.114.67) by smtp.huawei.com (10.3.19.209) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 25 Sep 2020 08:57:16 +0800 Subject: Re: [PATCH] f2fs: compress: fix to disallow enabling compress on non-empty file To: Jaegeuk Kim CC: , , References: <20200918030349.19667-1-yuchao0@huawei.com> <20200924200305.GA2568648@google.com> From: Chao Yu Message-ID: Date: Fri, 25 Sep 2020 08:57:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200924200305.GA2568648@google.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.136.114.67] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/9/25 4:03, Jaegeuk Kim wrote: > On 09/18, Chao Yu wrote: >> Compressed inode and normal inode has different layout, so we should >> disallow enabling compress on non-empty file to avoid race condition >> during inode .i_addr array parsing and updating. >> >> Signed-off-by: Chao Yu >> --- >> fs/f2fs/file.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >> index 58e464cc15f0..139fdfc1dc55 100644 >> --- a/fs/f2fs/file.c >> +++ b/fs/f2fs/file.c >> @@ -1821,6 +1821,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) >> if (iflags & F2FS_COMPR_FL) { >> if (!f2fs_may_compress(inode)) >> return -EINVAL; >> + if (inode->i_size) > > Changed like this. > > + if (S_ISREG(inode->i_mode) && inode->i_size) My bad, thanks for fixing this. :) Thanks, > > >> + return -EINVAL; >> >> set_compress_context(inode); >> } >> -- >> 2.26.2 > . >