Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp876125pxk; Thu, 17 Sep 2020 20:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx3CuYq8Z2YxpuukXBZtKo5gG6KSNLvhaMj/mgQOffUKkIzqjVsVQFNG/8dmZTbpe+64/ae X-Received: by 2002:a50:eb0a:: with SMTP id y10mr21812256edp.89.1600398151807; Thu, 17 Sep 2020 20:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398151; cv=none; d=google.com; s=arc-20160816; b=HgtXvzRzubUZS69jwJhUwX6B5eyufjpzMDCM7uxiEe5wUmXHLKbM+T6GOCy4yjEDyc cuG5I16yTFvWkZWjEf8dsszKzqKGUbtE0lF49wP/DJxBmget2jnFgsJSIJCZGF4GCxhw jGSKHSGsiR81aIRDZacbgc3ujJOe/vyuuNoi0ydzrh2nV/6txGqd5BbZUPAY4TIFxvTp b+0kyrjN1vKDuZYDHiHNhXESDFElFmqAtpk66Y4lbBN2QTYB5btqrX0U7YlwRBRhtlWr a6W6E8+XC/HCuBeCBQyUZgJpMUHbJYChrBfs9GOo2dqgs9W5tPt5Zj0IGLRQGuiWYZdv L3yQ== 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=AJClniacXGE6fETImFUsIPmxmAu6uyIDqIxoTJy4pRY=; b=nTKmHbhkZCqs4SqD6wAdHc6W+2LVw8gpdBf2ycaMgEggGcjugxY5n+nclYeN8BxXjo g6X3Jke8j3l91zSIVpSpoIuury4sZa1ZIRXItk0hZeowZfpRAeq6rjETGFgDS3LFSR9D pmpS4gYmfej2eyeb8dWuZ6GXtWpOzeJYf6yeF41OSaruqPzhcVNW7eEnRpoPJbPU/kgL uHRbcO8WfeCVnuJL/rixh1h0xQbR75WfdHtMVChbCiA0ZcB33nCe0Drpe5dnAiQZJhM+ C9aGzNtiGRQeauxDj5NmEzg0qJdxZyV0NOsvYPLrzWhwjz15LEWvL0NrmSeVTkmrNFZt 7KLQ== 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 a8si1227942ejs.101.2020.09.17.20.02.08; Thu, 17 Sep 2020 20:02: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 S1728196AbgIRC6r (ORCPT + 99 others); Thu, 17 Sep 2020 22:58:47 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13286 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726705AbgIRC6l (ORCPT ); Thu, 17 Sep 2020 22:58:41 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 92998A3469232E76FC6F; Fri, 18 Sep 2020 10:58:39 +0800 (CST) Received: from [10.136.114.67] (10.136.114.67) by smtp.huawei.com (10.3.19.213) with Microsoft SMTP Server (TLS) id 14.3.487.0; Fri, 18 Sep 2020 10:58:36 +0800 Subject: Re: [PATCH 6/9] f2fs: zstd: Switch to the zstd-1.4.6 API To: Eric Biggers CC: Nick Terrell , Johannes Weiner , "Nick Terrell" , Yann Collet , "linux-kernel@vger.kernel.org" , "linux-f2fs-devel@lists.sourceforge.net" , Petr Malat , "Chris Mason" , Kernel Team , Niket Agarwal References: <20200916034307.2092020-1-nickrterrell@gmail.com> <20200916034307.2092020-9-nickrterrell@gmail.com> <28bf92f1-1246-a840-6195-0e230e517e6d@huawei.com> <9589E483-A94B-4AF6-8C03-B0763715B40A@fb.com> <20200918025627.GA3518637@gmail.com> From: Chao Yu Message-ID: <6eb268c8-7276-5859-e5b0-ce0a541e27e7@huawei.com> Date: Fri, 18 Sep 2020 10:58:35 +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: <20200918025627.GA3518637@gmail.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/18 10:56, Eric Biggers wrote: > On Fri, Sep 18, 2020 at 09:47:32AM +0800, Chao Yu wrote: >> Ah, I got it. >> >> Step of enabling compressed inode is not correct, we should touch an empty >> file, and then use 'chattr +c' on that file to enable compression, otherwise >> the race condition could be complicated to handle. So we need below diff to >> disallow setting compression flag on an non-empty file: >> >> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >> index 8a422400e824..b462db7898fd 100644 >> --- a/fs/f2fs/file.c >> +++ b/fs/f2fs/file.c >> @@ -1836,6 +1836,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 (get_dirty_pages(inode) || fi->i_compr_blocks) >> + return -EINVAL; >> >> set_compress_context(inode); >> } > > Why not: > > if (inode->i_size) > return -EINVAL; Yeah, I noticed that after replying this email, I've prepared the new patch which including the i_size check. Thanks for noticing this. Thanks, > . >