All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: Johannes Weiner <jweiner@fb.com>,
	Nick Terrell <nickrterrell@gmail.com>, Yann Collet <cyan@fb.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>,
	Petr Malat <oss@malat.biz>, Chris Mason <clm@fb.com>,
	Nick Terrell <terrelln@fb.com>, Kernel Team <Kernel-team@fb.com>,
	Niket Agarwal <niketa@fb.com>
Subject: Re: [f2fs-dev] [PATCH 6/9] f2fs: zstd: Switch to the zstd-1.4.6 API
Date: Thu, 17 Sep 2020 19:56:27 -0700	[thread overview]
Message-ID: <20200918025627.GA3518637@gmail.com> (raw)
In-Reply-To: <a8b6e21d-fb51-1a50-8f2a-045f3a496c12@huawei.com>

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;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Eric Biggers <ebiggers@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: Nick Terrell <terrelln@fb.com>, Johannes Weiner <jweiner@fb.com>,
	Nick Terrell <nickrterrell@gmail.com>, Yann Collet <cyan@fb.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-f2fs-devel@lists.sourceforge.net" 
	<linux-f2fs-devel@lists.sourceforge.net>,
	Petr Malat <oss@malat.biz>, Chris Mason <clm@fb.com>,
	Kernel Team <Kernel-team@fb.com>, Niket Agarwal <niketa@fb.com>
Subject: Re: [PATCH 6/9] f2fs: zstd: Switch to the zstd-1.4.6 API
Date: Thu, 17 Sep 2020 19:56:27 -0700	[thread overview]
Message-ID: <20200918025627.GA3518637@gmail.com> (raw)
In-Reply-To: <a8b6e21d-fb51-1a50-8f2a-045f3a496c12@huawei.com>

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;

  reply	other threads:[~2020-09-18  2:56 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-16  3:42 [PATCH 0/9] Update to zstd-1.4.6 Nick Terrell
2020-09-16  3:42 ` [f2fs-dev] " Nick Terrell
2020-09-16  3:42 ` [PATCH 1/9] lib: zstd: Add zstd compatibility wrapper Nick Terrell
2020-09-16  3:42   ` [f2fs-dev] " Nick Terrell
2020-09-16  8:48   ` Christoph Hellwig
2020-09-16  8:48     ` [f2fs-dev] " Christoph Hellwig
2020-09-16 20:21     ` Nick Terrell
2020-09-16 20:21       ` [f2fs-dev] " Nick Terrell via Linux-f2fs-devel
2020-09-16  3:42 ` [PATCH 2/9] lib: zstd: Add decompress_sources.h for decompress_unzstd Nick Terrell
2020-09-16  3:42   ` [f2fs-dev] " Nick Terrell
2020-09-16  3:42 ` [f2fs-dev] [PATCH 3/9] lib: zstd: Upgrade to latest upstream zstd version 1.4.6 Nick Terrell
2020-09-16  3:42   ` Nick Terrell
2020-09-16  8:01   ` kernel test robot
2020-09-16  8:01     ` kernel test robot
2020-09-16  8:01   ` kernel test robot
2020-09-16 20:53   ` Nick Terrell
2020-09-16 20:53     ` [f2fs-dev] " Nick Terrell via Linux-f2fs-devel
2020-09-16  3:42 ` [PATCH 4/9] crypto: zstd: Switch to zstd-1.4.6 API Nick Terrell
2020-09-16  3:42   ` [f2fs-dev] " Nick Terrell
2020-09-16  8:49   ` Christoph Hellwig
2020-09-16  8:49     ` [f2fs-dev] " Christoph Hellwig
2020-09-16  3:42 ` [PATCH 5/9] btrfs: zstd: Switch to the " Nick Terrell
2020-09-16  3:42   ` [f2fs-dev] " Nick Terrell
2020-09-16  8:49   ` Christoph Hellwig
2020-09-16  8:49     ` [f2fs-dev] " Christoph Hellwig
2020-09-16 14:20     ` Chris Mason
2020-09-16 14:20       ` [f2fs-dev] " Chris Mason via Linux-f2fs-devel
2020-09-16 14:30       ` Christoph Hellwig
2020-09-16 14:30         ` [f2fs-dev] " Christoph Hellwig
2020-09-16 14:43         ` Chris Mason
2020-09-16 14:43           ` [f2fs-dev] " Chris Mason via Linux-f2fs-devel
2020-09-16 14:46           ` Christoph Hellwig
2020-09-16 14:46             ` [f2fs-dev] " Christoph Hellwig
2020-09-16 15:01             ` Chris Mason
2020-09-16 15:01               ` [f2fs-dev] " Chris Mason via Linux-f2fs-devel
2020-09-16 18:27             ` Eric Biggers
2020-09-16 18:27               ` [f2fs-dev] " Eric Biggers
2020-09-16 19:18             ` Nick Terrell
2020-09-16 19:18               ` [f2fs-dev] " Nick Terrell via Linux-f2fs-devel
2020-09-17  1:35               ` Rik van Riel
2020-09-17 10:04                 ` Christoph Hellwig
2020-09-17 10:04                   ` [f2fs-dev] " Christoph Hellwig
2020-09-17 14:28                   ` Chris Mason
2020-09-17 14:28                     ` [f2fs-dev] " Chris Mason via Linux-f2fs-devel
2020-09-17 17:57                     ` Nick Terrell
2020-09-17 17:57                       ` [f2fs-dev] " Nick Terrell via Linux-f2fs-devel
2020-09-16  3:43 ` [PATCH 6/9] f2fs: " Nick Terrell
2020-09-16  3:43   ` [f2fs-dev] " Nick Terrell
2020-09-16  6:31   ` Chao Yu
2020-09-16  6:31     ` Chao Yu
2020-09-16 18:39     ` [f2fs-dev] " Nick Terrell via Linux-f2fs-devel
2020-09-16 18:39       ` Nick Terrell
2020-09-17  6:31       ` [f2fs-dev] " Chao Yu
2020-09-17  6:31         ` Chao Yu
2020-09-17 18:00         ` [f2fs-dev] " Nick Terrell via Linux-f2fs-devel
2020-09-17 18:00           ` Nick Terrell
2020-09-17 19:34           ` [f2fs-dev] " Nick Terrell via Linux-f2fs-devel
2020-09-17 19:34             ` Nick Terrell
2020-09-18  1:47             ` [f2fs-dev] " Chao Yu
2020-09-18  1:47               ` Chao Yu
2020-09-18  2:56               ` Eric Biggers [this message]
2020-09-18  2:56                 ` Eric Biggers
2020-09-18  2:58                 ` [f2fs-dev] " Chao Yu
2020-09-18  2:58                   ` Chao Yu
2020-09-18  5:39               ` [f2fs-dev] " Nick Terrell via Linux-f2fs-devel
2020-09-18  5:39                 ` Nick Terrell
2020-09-18  1:41           ` [f2fs-dev] " Chao Yu
2020-09-18  1:41             ` Chao Yu
2020-09-16  3:43 ` [PATCH 7/9] squashfs: " Nick Terrell
2020-09-16  3:43   ` [f2fs-dev] " Nick Terrell
2020-09-16  3:43 ` [PATCH 8/9] lib: unzstd: " Nick Terrell
2020-09-16  3:43   ` [f2fs-dev] " Nick Terrell
2020-09-16  3:43 ` [PATCH 9/9] lib: zstd: Remove zstd compatibility wrapper Nick Terrell
2020-09-16  3:43   ` [f2fs-dev] " Nick Terrell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200918025627.GA3518637@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=Kernel-team@fb.com \
    --cc=clm@fb.com \
    --cc=cyan@fb.com \
    --cc=jweiner@fb.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickrterrell@gmail.com \
    --cc=niketa@fb.com \
    --cc=oss@malat.biz \
    --cc=terrelln@fb.com \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.