From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs: inode: Don't compress if NODATASUM or NODATACOW set
Date: Tue, 25 Jun 2019 16:24:57 +0800 [thread overview]
Message-ID: <95e8171b-6d08-e989-a835-637ccf2efe76@gmx.com> (raw)
In-Reply-To: <20180515073622.18732-2-wqu@suse.com>
[-- Attachment #1.1: Type: text/plain, Size: 2302 bytes --]
Ping?
This patch should fix the problem of compressed extent even when
nodatasum is set.
It has been one year but we still didn't get a conclusion on where
force_compress should behave.
But at least to me, NODATASUM is a strong exclusion for compress, no
matter whatever option we use, we should NEVER compress data without
datasum/datacow.
So I still want to push this patch as is.
Thanks,
Qu
On 2018/5/15 下午3:36, Qu Wenruo wrote:
> As btrfs(5) specified:
>
> Note
> If nodatacow or nodatasum are enabled, compression is disabled.
>
> If NODATASUM or NODATACOW set, we should not compress the extent.
>
> Normally NODATACOW is detected properly in run_delalloc_range() so
> compression won't happen for NODATACOW.
>
> However for NODATASUM we don't have any check, and it can cause
> compressed extent without csum pretty easily, just by:
> ------
> mkfs.btrfs -f $dev
> mount $dev $mnt -o nodatasum
> touch $mnt/foobar
> mount -o remount,datasum,compress $mnt
> xfs_io -f -c "pwrite 0 128K" $mnt/foobar
> ------
>
> And in fact, we have bug report about corrupted compressed extent
> without proper data checksum so even RAID1 can't recover the corruption.
> (https://bugzilla.kernel.org/show_bug.cgi?id=199707)
>
> Running compression without proper checksum could cause more damage when
> corruption happens, so there is no need to allow compression for
> NODATACSUM.
>
> Reported-by: James Harvey <jamespharvey20@gmail.com>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/inode.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d241285a0d2a..dbef3f404559 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -396,6 +396,14 @@ static inline int inode_need_compress(struct inode *inode, u64 start, u64 end)
> {
> struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
>
> + /*
> + * Btrfs doesn't support compression without csum or CoW.
> + * This should have the highest priority.
> + */
> + if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATACOW ||
> + BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM)
> + return 0;
> +
> /* force compress */
> if (btrfs_test_opt(fs_info, FORCE_COMPRESS))
> return 1;
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-06-25 8:25 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-15 7:36 [PATCH 0/2] btrfs: Enhance btrfs handling compression and Qu Wenruo
2018-05-15 7:36 ` [PATCH 1/2] btrfs: inode: Don't compress if NODATASUM or NODATACOW set Qu Wenruo
2018-05-15 8:21 ` Nikolay Borisov
2018-05-15 8:30 ` Qu Wenruo
2018-05-15 8:35 ` Nikolay Borisov
2018-05-15 8:48 ` Qu Wenruo
2018-05-15 10:36 ` Nikolay Borisov
2018-05-15 10:48 ` Qu Wenruo
2019-06-25 8:24 ` Qu Wenruo [this message]
2019-06-27 14:58 ` David Sterba
2019-06-28 1:26 ` Qu Wenruo
2019-06-28 11:34 ` David Sterba
2019-06-28 12:09 ` Qu Wenruo
2019-06-28 16:38 ` David Sterba
2019-06-28 2:47 ` Anand Jain
2019-06-28 5:58 ` Qu Wenruo
2019-06-28 6:56 ` Anand Jain
2019-06-28 7:09 ` Qu Wenruo
2018-05-15 7:36 ` [PATCH 2/2] btrfs: lzo: Avoid decompressing obviously corrupted data Qu Wenruo
2018-05-15 8:05 ` Nikolay Borisov
2018-05-15 8:32 ` Qu Wenruo
2018-05-15 8:34 ` Nikolay Borisov
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=95e8171b-6d08-e989-a835-637ccf2efe76@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).