Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp589673pxk; Thu, 24 Sep 2020 13:07:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYFyen6iWGwEqD7OeFHKTl3WsV0z3RSvnmj7KFVdBUDPgc7f8kH25v7DaAUv0rqp9afCWv X-Received: by 2002:a17:906:5f8a:: with SMTP id a10mr315529eju.502.1600978047260; Thu, 24 Sep 2020 13:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600978047; cv=none; d=google.com; s=arc-20160816; b=QlDo0mttDvmWVAqOqpffM2DQ2ORLjEcOyyR4JNZaGGWK7FYmvLfmr35FcoGkQJJZcC SncE+cyS4tVR9+uNI+FsWn763wVBV0MVw+lbfGauNwJgwCPjn2TM0PprewXuAZ5ayGaW Kml+3obrtD411dYas3za0LeeSkHz3Du6yJb5Oghog+YmLCcst7cM8FSA5nz4OJ4C/M4l Fv997OG57ONlu7j3FZ4mvmVIeBmOJxXWTLY8zJqXuw9UBf26O9GwMzf3YgmEo992GbMe 3nGDc9tJZXUooNSsv6oqAdipn9hqhJ3ay41dIL/NuYv7CZjNcG3c2G72LrMULP552Wt/ 6KAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3UZ74bBhZsWR1uph0JAak8WFzkzqogzRIak985IrpYg=; b=TUf73tAdFEmvbEGA0d4QMYZGeNr4u8Mc3Cu0/7sAggs/pvWoDy+yeNxhkykJTCn9yk 0t/i863rML8q48UWaGkau+kcGXYQfEAjqAoVldLcly3qa/vJ57Vuu3qwG2W1somLIbXJ 6Y2gFRLQNj4ogK4kiV0i+ICcyz6NqC2AXPhcyG21Y0/Exf6ThNEQSYZAlwcHLmpfZNoH 3wCMadjwPP2WqZHXNeVZjtg5Nuw1s8KoVssSq2f5OCgYBR6XaVYleeb1j8HqkFqIbJNy 4aRWK6XHyjoLyzLnMurZju15VHfGON1WfhNstErZiCOR5U1rRpCxhIWwrVXNlj+IDi6l wUIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q9VS01GB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h11si308012edr.319.2020.09.24.13.07.04; Thu, 24 Sep 2020 13:07:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Q9VS01GB; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbgIXUDG (ORCPT + 99 others); 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