пн, 14 мая 2018 г. в 20:32, David Sterba <dste...@suse.cz>: > On Mon, May 14, 2018 at 03:02:10PM +0800, 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. > > > > And in fact, we have bug report about corrupted compressed extent > > leading to memory corruption in mail list.
> Link please. > > Although it's mostly buggy lzo implementation causing the problem, btrfs > > still needs to be fixed to meet the specification. > That's very vague, what's the LZO bug? If the input is garbage and lzo > decompression cannot decompress it, it's not a lzo bug. > > Reported-by: James Harvey <jamespharve...@gmail.com> > > Signed-off-by: Qu Wenruo <w...@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; > This is also the wrong place to fix that, NODATASUM or NODATACOW inode > should never make it to compress_file_range (that calls > inode_need_compress). David, i've talk about that some time ago: https://www.spinics.net/lists/linux-btrfs/msg73137.html NoCow files can be *easy* compressed. ``` ➜ ~ touch test ➜ ~ chattr +C test ➜ ~ lsattr test ---------------C-- test ➜ ~ dd if=/dev/zero of=./test bs=1M count=1 1+0 records in 1+0 records out 1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00099878 s, 1.0 GB/s ➜ ~ sync ➜ ~ filefrag -v test Filesystem type is: 9123683e File size of test is 1048576 (256 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 255: 88592741.. 88592996: 256: last,eof test: 1 extent found ➜ ~ btrfs fi def -vrczstd test test ➜ ~ filefrag -v test Filesystem type is: 9123683e File size of test is 1048576 (256 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 31: 3125.. 3156: 32: encoded 1: 32.. 63: 3180.. 3211: 32: 3157: encoded 2: 64.. 95: 3185.. 3216: 32: 3212: encoded 3: 96.. 127: 3188.. 3219: 32: 3217: encoded 4: 128.. 159: 3263.. 3294: 32: 3220: encoded 5: 160.. 191: 3355.. 3386: 32: 3295: encoded 6: 192.. 223: 3376.. 3407: 32: 3387: encoded 7: 224.. 255: 3411.. 3442: 32: 3408: last,encoded,eof test: 8 extents found ``` -- Have a nice day, Timofey. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html