From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3C08C43464 for ; Fri, 18 Sep 2020 02:56:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 886BB206B6 for ; Fri, 18 Sep 2020 02:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600397810; bh=btqXYTF0PNPv/mb8paQ68oaE4+SHI3dRRxApfP+mkmw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=aMBk/uc6jt1NdsG8X+URdBpD5EYrumk4l/TGvH2S/HwBledO62Fo76gwThuztBtPj rLTj0QmQZhFk0H1iZfIypG3RS/r1c4ZsgMz2lJ5qOCM8DHA5lZDB3LYrRPcpyQlTbM kthvV8CDaWZbll55uy1dFw5SZtbagqKDmZA/kB1w= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728414AbgIRC4t (ORCPT ); Thu, 17 Sep 2020 22:56:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:56058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730360AbgIRC43 (ORCPT ); Thu, 17 Sep 2020 22:56:29 -0400 Received: from gmail.com (unknown [104.132.1.76]) (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 1FB8E206B6; Fri, 18 Sep 2020 02:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600397789; bh=btqXYTF0PNPv/mb8paQ68oaE4+SHI3dRRxApfP+mkmw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HcFsvhzc6CeEQ2WObijhFV05KNALsNgNCaTmUQZomWYV8hLpjWsCgGVMHDragVd5F zhsUNf/clR7+8Drg1VGRAXaXEFpPCkw3Bi/BTmxg/IUtooLBLifg9tgtO6u00Jy/1n rD0qAz3zWclop2Fw4CQbTItr5M0orjqojFzNcmYE= Date: Thu, 17 Sep 2020 19:56:27 -0700 From: Eric Biggers To: Chao Yu 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 Subject: Re: [PATCH 6/9] f2fs: zstd: Switch to the zstd-1.4.6 API Message-ID: <20200918025627.GA3518637@gmail.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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;