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=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 6992AC4363D for ; Thu, 24 Sep 2020 20:03:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 02A382344C for ; Thu, 24 Sep 2020 20:03:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600977788; bh=4qmfMtKFtj1GJGkFkWVAtlMq33rZaTCs31/4IdPYFgU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=CtwAIw9EmODwY1dvw/sSgv231ImroqIIz3AjeiU31Rl/FlkNTpiVIrDgcMOe0X77J h0bmcO9k29x0R7v+9CN7eJLJ+TmgxkrJYK+ymlNHfiQzjsa1h6eec2kyzKOIqPFRfG CbaCbOCV6XhKRBaQsdJz8vnFy+v0Ehi3BQXRTDvk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbgIXUDG (ORCPT ); Thu, 24 Sep 2020 16:03:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:52068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726037AbgIXUDG (ORCPT ); Thu, 24 Sep 2020 16:03:06 -0400 Received: from localhost (unknown [104.132.1.66]) (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 CC48621707; Thu, 24 Sep 2020 20:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600977786; bh=4qmfMtKFtj1GJGkFkWVAtlMq33rZaTCs31/4IdPYFgU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q9VS01GBzz6O6mO0j9z64QuPZISKKrv+9/L5RHqR2fvjRa2GE52yanS/0NdJ5me/Q ZvAnEk+SO6dz4UyHxJUC4XQAkSOv348iREjEmnJluefIBb0SZrypQkR0t2u4tuCThC YUNOLt3BSKhff+6NGw16fzuu0oX8md72JUsAwhAY= Date: Thu, 24 Sep 2020 13:03:05 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org Subject: Re: [PATCH] f2fs: compress: fix to disallow enabling compress on non-empty file Message-ID: <20200924200305.GA2568648@google.com> References: <20200918030349.19667-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200918030349.19667-1-yuchao0@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) > + return -EINVAL; > > set_compress_context(inode); > } > -- > 2.26.2